Project Description
The Map Test Framework makes it easier for BizTalk developers to test their maps. You'll no longer have to maintain a whole bunch of XML files for your tests. The use of template files and xpath queries to perform tests will increase your productivity tremendously.

To illustrate how easy the Map Test Framework works, let's walk through an example. The following code snippet shows a test for transforming a single value to a fixed length string of 10 characters. When the string is smaller than the maximum length, it should be padded with leading spaces.

/// Tests a field that should map to a fixed-length string.
/// When the string is smaller than 10 characters,
/// it should be padded with leading spaces.
public void TestFieldPadWithSpaces()
// Setup testcase collection. XPath queries correspond to the source and destination element respectively.
MapTestCases allTestCases = new MapTestCases(
"/*[local-name()='Root' and namespace-uri()='http://MySampleProject.Schemas.Schema1']" +
"/*[local-name()='Record' and namespace-uri()='']" +
"/*[local-name()='Field_ToBePadded' and namespace-uri()='']",
"/*[local-name()='Root2' and namespace-uri()='http://MySampleProject.Schemas.Schema2']" +
"/*[local-name()='Record' and namespace-uri()='']" +
"/*[local-name()='Field_Padded' and namespace-uri()='']"

// When the source element is removed also the destination element should be removed
allTestCases.AddTestCase(null, null);
// Empty source element means empty destination element
allTestCases.AddTestCase(string.Empty, string.Empty);
// Test cases for values with length 9, 10 and 11
allTestCases.AddTestCase("123456789", " 123456789");
allTestCases.AddTestCase("1234567890", " 1234567890");
allTestCases.AddTestCase("12345678901", "1234567890");


First, a MapTestCases instance is created with the xpath queries of the source and destination elements as arguments. The MapTestCases instance will contain all test cases that should be run against the map. Next, five test cases are added to the collection by invoking the method AddTestCase. It allows you to specify the source and expected destination value. Note that a null value means that the element is removed from the xml. Finally, all test cases are being run by simply invoking the ExecuteMapTest method. Not only does it run the map, it also compares the actual with the expected result. Note that the ExecuteMapTest method is contained in a base class which is provided by this framework. The test class containing this method should derive from it.
Of course, there is more to it than this. I mean, where do I setup the xml files for example? The idea of this example is to show you, that after setting up, it’s just a matter of writing tests like the one above. No xml editing needed. How easy is that? See the documentation for a complete example including setup.
OK. So let’s list some more benefits of this framework:
  • Maintainability. Tests can be based on just two xml files that server as templates. One as the source xml file and one as the expected result xml file. No more editing of countless xml files when changing the schema. The framework generates the source and expected files for you based on the xpath queries and the values you specify.
  • Productivity. Run test cases including xml comparison by invoking only a single method.
  • Completeness. All kinds of scenarios are possible including advanced scenarios such as testing for the current date and time. You can even test GUIDs to some extent.
  • Compatibility. The framework leverages the new unit test capabilities of BizTalk Server 2009.
  • Agility. The framework allows Test Driven Development.
  • If I managed to get you curious, just download the latest version or have a look at the HOWTO for more details. The download will also include a sample project that shows you all kinds of scenarios the framework can handle. You’ll be up and running in no time.

    Last edited Jan 1, 2011 at 8:58 PM by dm_denheijer, version 8