BizTalk Server 2013: Step-by-Step to implement Unit Testing in Schemas and Maps (Part 2)

  • Sandro Pereira
  • Aug 29, 2014
  • 4 min read

In my last post, I explained how to implement unit testing for schemas and maps in a BizTalk Server 2013 project using Visual Studio 2012. I also mentioned an issue that occurs when testing maps. Every time the unit test runs, Visual Studio throws the following error:

  • Microsoft.BizTalk.TestTools.BizTalkTestAssertFailException: Transform Failure.

Until Microsoft releases a hotfix (likely in a future CU), my previous post described a workaround. The solution used a custom wrapper class based on Microsoft.BizTalk.TestTools.dll.

However, Paul Nichols from Mexia pointed me to a post by Michael Stephenson (BizTalk 2013 Map Unit Testing Gotcha). It suggested using a Test Settings file to force tests to run in 32-bit mode. This approach avoids the need for a custom assembly. I decided to try it.

📝 One-Minute Brief

You can fix the BizTalk 2013 map unit testing “Transform Failure” error by adding a .testsettings file to the Visual Studio test project and running tests in 32-bit mode. This workaround eliminates the need for a custom wrapper assembly.

Understanding .runsettings vs .testsettings

Unit tests in Visual Studio 2012 can be configured by using a .runsettings file (.runsettings is new in Visual Studio 2012 – if you’re familiar with unit testing in previous versions of Visual Studio, you might know about .testsettings files). For example, you can change the .NET Framework on which the tests will be run, the directory where test results are delivered, and the data collected during a test run.

You can still use .testsettings in Visual Studio 2012, so any test configurations you wrote for previous editions will still work. But .testsettings can be used only to configure tests written for the MSTest adapter. By contrast, .runsettings can be used with any of the adapters built for the extensible unit test framework in Visual Studio 2012, such as xUnit.net and NUnit.

You still need a .testsettings file for some kinds of tests:

  • Tests that are deployed in a lab environment.
  • Web performance and load tests.
  • Customizing some types of diagnostic data adapters, such as IntelliTrace and enterprise logging.
  • BizTalk Server maps (workaround).

Maps Unit Testing Workaround 2 (add .testsettings file)

Unfortunately, if we add a .runsettings file and force the tests to run in 32-bit mode, see an example of this Test Settings file here, our test project still doesn’t work!

However, when I used a .testsettings file — either copied from a Visual Studio 2010/BizTalk Server 2010 solution or created inside the BizTalk Server 2013 solution — the tests worked. I cannot fully explain why, but it consistently fixes the problem.

How to Fix the Error

So to accomplish this, we need to:

  • Right-click on the BizTalk solution name: Solution ‘UnitTestingFeatureWithMaps’ (2 projects), and select Add and then New Item…
Visual-Studio 2012 Add New TestSettings file
  • In the Add New Item – Solution Items dialog box, expand Installed and then choose Test Settings.
  • From the list of items, select Test Settings.
Visual Studio 2012 Add New Item Solution Items
  • In the Name box, enter TestSettings.testsettings, and then click Add.
  • This will open a new window for us to specify the settings of the test settings file. Just leave the default setting by clicking Close.
Visual Studio 2012 Test Settings Window

You can add more than one test settings file if you want to be able to switch quickly between different settings.

  • On the Visual Studio main menu, choose Test, choose Test Settings, and then choose Test Settings File.
Test Settings Select Test Settings File
  • In the Open Setting File window, select the test setting file that we previous create: TestSettings.testsettings.
Test Settings Select Test Settings File

So if we perform the tests again, we will notice that the Microsoft.BizTalk.TestTools.BizTalkTestAssertFailException: Transform Failure is solved, and the only error that is happening is about a Map output validation failure (intentionally present)

BizTalk Server 2013 Map Unit Testing result

Thank you, Paul Nichols, for your comments.

Thanks for Buying me a coffe
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

2 thoughts on “BizTalk Server 2013: Step-by-Step to implement Unit Testing in Schemas and Maps (Part 2)”

  1. I’m glad there’s a simple solution to a terrible exception which really gives you no clue about what’s wrong

  2. Hi Admin! Nice Blog very informative (Y)

    I have a suggestion -please improve the design of blog, for a beginner start from very first blog post is tough so make it navigable by page nnumber.

    Thanks
    Rahul

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top