Monday, January 17, 2011

BizTalk Map test framework

For testing BizTalk solutions the combination of BizUnit and the orchestration profiler are the way to go. Setting it up for a new project can be a hassle, although i appreciate it’s flexibility with the easy of adding custom BizUnit steps.

I just came across a new framework that provides some usefull means of testing BizTalk artefacts, namely maps.

As you might have noticed the support for testing in BizTalk 2009 / BizTalk 2010 is somewhat limited and it forces you to build your artefacts with additional code for mere testing only (the check ‘Enable Unit Test’ will generate a wrapper around the components such as the TestableMapBase in the example below)….the most you will get out of the standard map testing is a validate instance of your message:

Microsoft.BizTalk.TestTools.Mapper.TestableMapBase mapTest = new MapTest.Input2Output();

mapTest.TestMap(
    @"Input.xml",   Microsoft.BizTalk.TestTools.Schema.InputInstanceType.Xml,
     "Output.xml",  Microsoft.BizTalk.TestTools.Schema.OutputInstanceType.XML);

This can be overcome by using a mapping helper component (e.g .from Michael Stephenson) that does a Binary or Xml validation of the result, nevertheless you don’t want to write this on your own.

MapTestingHelper.ValidateMapOutput("Output.xml", “Output.xml");

I’ve tried out the BizTalk map test framework and it allows you to write your testcases using Xpath on fields that you dynamically want to fill with dummy values and predicted outcomes.

Let’s say you want to test a value mapping that returns different results based on the input you can simply write a method that does this validation in just a few lines:

MapTestCases collection = new MapTestCases(
"/*[local-name()='Input']/*[local-name()='InputValue']",
"/*[local-name()='Output']/*[local-name()='ValueOut']"               );

            collection.AddTestCase(
                new string[] { "TEST" }, new string[] { "TRUE" }
                );

            collection.AddTestCase(
                new string[] { "AAH" }, new string[] { "FAL3SE" }
                );

            base.ExecuteMapTest(collection);
            return;

 

I think i like it….check it out here: BizTalk map test framework

Sunday, January 16, 2011

BizTalk Unit testing – heads up

BizTalk Unit testing was before the release of BizTalk 2009 not an integral part of the product. The community anticipated with awesome frameworks and tools:



Very stable framework that is a wrapper around NUnit that allows testing using BizUnit steps, complemented with additional steps (BizUnitExtensions) and incorperated in the (BizTalk Software Factory). This is the framework that suits all your needs by allowing custom BizUnit step development in .Net and uses an Xml based approach.



Very stable framework developed by Tomas Restrepo, very nice and easy to understand.



Profiler that allows for code coverage by querying the BizTalk database and generating reports on the orchestration shape coverage, allowing insight in the completeness of the test.


Present day



    A new framework has been introduced, that is fitted for one purpose, testing maps using an approach of dynamically reading/manipulating Xml fields by XPath expressions that can be set up in code.



    In my next posts i will show my positive experience with the latter!


    For your reference here is a list of some common frameworks and areas of expertise;


    image



    Note: due to the popularity of BizUnit a lot of blogs are about steps that have been created, including steps that use the Pipelinetesting framework. That’s the reason, BizUnit passes all tests :)