Sunday, August 23, 2009

New BizTalk Unit Testing Framework : “Bizmonade”

For the past few months, I have been developing a new unit testing framework for BizTalk. This framework is specialized on unit testing Orchestrations, and unlike existing tools, it allows testing orchestrations without first deploying into BizTalk and without doing any configuration (bindings). The project is now complete enough to release a “preview” version. It still lacks important features, but it is a working implementation and I would be very interested in hearing feedback from the BizTalk community.

Tests can be written in C# using NUnit, MSTest or any other .Net testing framework.

Example test written using this tool:

[Test]
public void TotalForOrder413ShouldBe14_99()
{
OrchestrationSimulator.Test<SubmitOrder__Simulated>()
.When(MessageReceived.FromFile<PurchaseOrder>(
Path.Combine(exampleInstancesPath, "PurchaseOrder_413.xml")
))
// Ensure the orchestration publishes an updated "PurchaseOrder" with the correct price quote
.ExpectMessageSent<PurchaseOrder>
(
msg =>
{
// NUnit asserts, if using another framework, substitute with that framework's syntax
Assert.AreEqual(14.99m, msg.DistinguishedFields["Total"]);
Assert.AreEqual("priceQuoteSubmitted", msg.PromotedProperties[typeof(orderStatus)]);
}
)
// Simulate that the client sent an "Approved Purchase Order" in response
// to the price quote.
.When(MessageReceived.FromFile<PurchaseOrder>(
Path.Combine(exampleInstancesPath, "PurchaseOrder_413_Approved.xml")
))
// Ensure the orchestration publishes the right Invoice in reaction to the approval
.ExpectMessageSent<Invoice>
(
// Not using NUnit asserts this time, can be used with any test framework,
// but provides less deatailed errors in case of failure (for now)
msg =>
msg.GetDistinguishedField<string>("Number") == "1") &&
msg.GetDistinguishedField<decimal>("TotalPrice") == 14.99m
)
// Ensure the orchestration completes successfully
.ExpectCompleted()
.ExecuteTest();
}


The tool does not depend on BizTalk’s orchestration engine, instead it provides its own implementation of the XLang/s language. It generates C# code from ODX files (using an interpreter generated with SableCC), and the generated C# code uses Bizmonade’s “fake orchestration engine” implementation. This allowed developing the tool without worrying about internal BizTalk implementation details.



More details and download on bizmonade.matricis.com.

5 comments:

  1. Hi Christos,

    Wow, this looks very interesting, and could be the answer to my BDD prayers! Looks to have been a very challenging technical achievement. Look forward to trying it out.

    Regards, Jason

    ReplyDelete
  2. Hey Christos,

    So far so fantastic. I've run into my first issue;

    C:\code\trunk\EvalBizMonade\BizSamples\ProcessPO.odx(225,35,225,35): error : [225,35] expecting: '&=', '=', '|=', '^=', '-=', '%=', '+=', '<<=', '>>=', '/=', '*=', '>>>='

    because the terminate or suspend shapes aren't supported yet (as outlined). We use these extensively in our design - capture exceptions, log and terminate or suspend. Just thought I'd feedback and give some encouragement. I'm convinced this is a game changer for BizTalk development - keep up the good work and if you decide to open source/take contributions, I'd be more than willing to help!

    Regards, Jason

    ReplyDelete
  3. Wow, wow, wow, wow - the missing piece in the BizTalk testing 'challenge'.

    Nick.

    ReplyDelete
  4. Impressive! IMHO the fact that BTS dev is not agile limits the product and its future, especially for new projects. Testing tools like these open new perspectives!

    I will give it a try soon and share my feedback...

    ReplyDelete
  5. Kudos! A very nice initiative and maybe the missing piece in the incomplete BizTalk testing story.

    Is there still progress on the development?

    ReplyDelete