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…”
- In the “Add New Item – Solution Items” dialog box, expand “Installed” and then choose “Test Settings”.
- From the list of items, select “Test Settings”.
- 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”.
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”.
- In the “Open Setting File” window select the test setting file that we previous create: “TestSettings.testsettings”
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)
Thank you Paul Nichols for your comments.