This article is a 101 on testing BizTalk artifacts within Visual Studio and a reference to available resources found on MSDN and the internet.
Testing an instance of document schema in Visual Studio is basic task you can perform. You can navigate to the schema within your BizTalk project. You right click on the schema in the Solution Explorer and choose properties. Before you test a schema through
Validate Instance you specify the Output Type, Input Instance Name, Output Instance Name, and Validate Instance Input Type. As input instance you can choose a document on your file system you wish to test if it adheres to the schema. After
selecting the document and specifying other details in the properties you can right click the schema and choose
Validate Instance. A window will pop up with information of the validation. In case the the Output window did not open and display information about whether the schema validation succeeded or failed, you can open it manually.
See Also MSDN
Instance Message Generation and Validation and
Testing of a map in Visual Studio is another basic task you can perform like validating a schema. You can navigate to the map within your BizTalk project. You right click on the map in the Solution Explorer and choose properties. Before you test a map through
Test Map you specify the TestMap Input, TestMap Input Instance, TestMap Output, TestMap Output Instance, Validate TestMap Input, and Validate TestMap Output. After selecting the document and specifying other details in the properties you can
right click the map and choose Test Map. A window will pop up with information of the test. In case the the Output window did not open and display information about whether the test succeeded or failed, you can open it manually.
See Also MSDN How to Test Maps and
How to Configure Map Validation and Test Parameters.
To unit test a schema you can leveraging the unit test framework in Visual Studio. You can follow the steps below, which is one of the approaches you can take:
TNWikiArticle tnw =
success = tnw.ValidateInstance(
Unit testing a schema means that the ValidateInstance method is used, which is similar as to choosing
Validate Instance on a schema in a BizTalk project (See
Test an instance of a document schema). ValidateInstance method is a member of
TestabaleSchemaBase class belonging to the namespace Microsoft.XLANGs.BaseTypes. When calling this method you have to provide the path to document, and the output instance type. The method will return a Boolean value indicating
if the validation was successful (true) or not (false).
See Also MSDN:
To unit test a map you can leveraging the unit test framework in Visual Studio. You can follow the steps below, which is one of the approaches you can take:
TNWikiArticleToUpdatedTNWikiArticle tnwiki =
output = @
tnwiki.TestMap(input, Microsoft.BizTalk.TestTools.Schema.InputInstanceType.Xml, output, Microsoft.BizTalk.TestTools.Schema.OutputInstanceType.XML);
Unit testing a map means that the TestMap method is used, which is similar as to choosing
Test Map on a map in a BizTalk project (See
Testing a Map). TestMap method is a member of TestabaleMapBase
class belonging also to the namespace Microsoft.XLANGs.BaseTypes. When calling this method you have to provide the path to a source document (instance), type of instance, path to location for output document (instance), and type of
output instance. This method will not return anything (i.e. void method). The way to check if the mapping has executed successfully is to validate if the output has been created.
To unit test a custom pipeline you can leveraging the unit test framework in Visual Studio. You can follow the steps below, which is one of the approaches you can take:
public void PipelineTNWikiAticleTagsUnitTest()
TNWikiAticleTags target = new TNWikiAticleTags();
//Collection of messages to test the pipeline
StringCollection documents = new StringCollection();
string strTNWikiArticle_XML = "..\\..\\TNWikiArticleInstance.xml";
// Only a body part for this test message so an empty
// collection will be passed.
StringCollection parts = new StringCollection();
// Dictionary mapping the schema to the namespace and type
// as displayed in the properties window for the *.xsd
string> schemas = new Dictionary<
string SchemaFile = "..//..//TNWikiArticle.xsd";
// Test the execution of the pipeline using the inputs
target.TestPipeline(documents, parts, schemas);
// Validate that the pipeline test produced the message
// which conforms to the schema.
string strMessages = Directory.GetFiles(testContextInstance.TestDir + "\\out", "Message*.out");
Assert.IsTrue(strMessages.Length > 0);
Schemas.TNWikiArticle tnWikiArticles= new Schemas.TNWikiArticle tnWikiArticles();
foreach (string outFile in strMessages)
The pipeline class in your project is derived from the Microsoft.BizTalk.TestTools.Pipeline.TestableReceivePipeline class, which models some of the same functionality exposed by the Pipeline.exe tool (See
You can perform easy tests through Visual Studio on a schema using Validate Instance. Mapping can be tested in Visual Studio using
Test Map. With Visual Studio you can also unit test the BizTalk artifacts schemas, maps and pipelines. Unfortunately you cannot unit test orchestrations. To unit orchestration you can use for instance using
Event Tracing for Windows (ETW). This framework can also be used to test other BizTalk artifacts. In case you want to test pipeline components you can use available frameworks online (See blog post
BizTalk Testing Series - Testing Pipeline Components).
Other suggested article to read:
Michael Stephenson has written an extensive series of blog post on testing in BizTalk Server (targeted on BizTalk 2009):
Steef-Jan Wiggers edited Revision 11. Comment: Adding text and links
Great article Steef-Jan, good overview and well described! Thumbs up!