More on Map Testing
Posted
by Michael Stephenson
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Michael Stephenson
Published on Sat, 29 Jan 2011 23:19:08 GMT
Indexed on
2011/01/30
7:26 UTC
Read the original article
Hit count: 275
I have been chatting with Maurice den Heijer recently about his codeplex project for the BizTalk Map Testing Framework (http://mtf.codeplex.com/).
Some of you may remember the article I did for BizTalk 2009 and 2006 about how to test maps but with Maurice's project he is effectively looking at how to improve productivity and quality by building some useful testing features within the framework to simplify the process of testing maps.
As part of our discussion we realized that we both had slightly different approaches to how we validate the output from the map. Put simple Maurice does some xpath validation of the data in various nodes where as my approach for most standard cases is to use serialization to allow you to validate the output using normal MSTest assertions.
I'm not really going to go into the pro's and con's of each approach because I think there is a place for both and also I'm sure others have various approaches which work too. What would be great is for the map testing framework to provide support for different ways of testing which can cover everything from simple cases to some very specialized scenarios.
So as agreed with Maurice I have done the sample which I will talk about in the rest of this article to show how we can use the serialization approach to create and compare the input and output from a map in normal development testing.
Prerequisites
One of the common patterns I usually implement when developing BizTalk solutions is to use xsd.exe to create .net classes for most of the schemas used within the solution. In the testing pattern I will take advantage of these .net classes.
The Map
In this sample the map we will use is very simple and just concatenates some data from the input message to the output message. Hopefully the below picture illustrates this well.
The Test
In the test I'm basically taking the following actions:
- Use the .net class generated from the schema to create an input message for the map
- Serialize the input object to a file
- Run the map from .net using the standard BizTalk test method which was generated for running the map
- Deserialize the output file from the map execution to a .net class representing the output schema
- Use MsTest assertions to validate things about the output message
The below picture shows this:
As you can see the code for this is pretty simple and it's all strongly typed which means changes to my schema which can affect the tests can be easily picked up as compilation errors. I can then chose to have one test which validates most of the output from the map, or to have many specific tests covering individual scenarios within the map.
Summary
Hopefully this post illustrates a powerful yet simple way of effectively testing many BizTalk mapping scenarios.
I will probably have more conversations with Maurice about these approaches and perhaps some of the above will be included in the mapping test framework.
The sample can be downloaded from here:
© Geeks with Blogs or respective owner