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

In my last post, I explained how to implement Unit Testing in Schemas and Maps in BizTalk Server 2013 project within Visual Studio 2012. I also describe that there is an issue when we try to perform Unit Testing in maps and each time we try to run the unit test it gives us the following error: “Microsoft.BizTalk.TestTools.BizTalkTestAssertFailException: Transform Failure

Until Microsoft fix this bug, probably in next releases of CU’s, one workaround that you can implement was described also in my last post, i.e., using a custom wrapper classes based on Microsoft.BizTalk.TestTools.dll to solved the current issues.

However, Paul Nichols from Mexia alerted me with a Michael Stephenson post: BizTalk 2013 Map Unit Testing Gotcha, to the fact that I could use a Test Settings file which forces the tests to run in 32-bit mode and solve the problem that I was facing with maps without having the necessity to use a custom assembly… so I decide to try it.

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 forces 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 if we take the “.testsettings” file that was generated for example in Visual Studio 2010/BizTalk Server 2010 and add this file to our Test project in Visual Studio 2012/BizTalk Server 2013 or if we add a new “.testsettings” file from our BizTalk solution it works and solve the problem that I was facing, I really don’t know why but is the best workaround that we can implement to solve all the problems.

So to accomplish this we need to:

  • Right click on the BizTalk solution name: “Solution ‘UnitTestingFeatureWithMaps’ (2 projects)”, and select “Add” and them “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 click “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-2

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.

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.

  • pauljamesnichols

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

  • Rahul

    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

One Platform Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

ServiceBus360

Azure service bus

Learn more

Start managing your Azure Service Bus namespaces in minutes

One Platform - Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

One Platform - Operations, Monitoring and Analytics Software
ServiceBus360

Azure service bus

Learn more

Start managing your Azure Service Bus namespaces in minutes

Back to Top