Overview
In today’s modern world of software development with continuous integration as a standard industry practice, what do you think would happen if you told a developer that they need to set a special Visual Studio project property in their build configuration in order for their code to “support unit testing”?
They would laugh at you in disbelief! Why does code need to be built in a special way in order to be testable?! This laughing typically would be followed by heart-ache, maybe a little quiet sobbing and an uncontrollable eye twitch as they realise that decade-old standard industry software development practices are crashing down all around them and they start reconsidering their life choices.
Sadly, the only thing that you can do is agree and try to console them by saying it is “just because it’s [technology xyz]".
This is the unfortunate world for a typical BizTalk developer using the out-of-the-box functionality.
And this embarrassing situation has other negative implications:
-
As described in Unit Testing with BizTalk Server Projects and Using the Unit Testing Feature with Schemas and Maps, BizTalk developers must set the Visual Studio project property “Enable Unit Testing” (under the Deployment tab) to “True”. This magically changes the base class of each BizTalk Map to “Microsoft.BizTalk.TestTools.Mapper.TestableMapBase” in order to “support unit testing”. Yes, an artefact’s base class is actually changed for that build – so what is being tested is not entirely the actual code that will be deployed into production. The difference between a Debug build and a Release build becomes more significant. (Admittedly for a BizTalk Map, this is less of a concern since the actual mapping is performed via XSLT under the covers and not directly by the base class, but the point is valid nevertheless – this approach is taken for other types of artefacts as well, and you really do not want to deploy Debug builds of any of those into a production environment…)
-
If you are like me and some teams I work with, you may want to develop and test the code off-premises (perhaps in your favourite cloud) and then deploy the release/deployment package to an on-premises test environment – where we also want to execute all the tests and have the test results recorded in the on-premises test and release management tools for all team members to access. However, a release/deployment package should never have that special project property set – and this prevents unit tests from compiling and executing against it.
-
When developing a BizTalk Map that uses a Scripting Functoid configured to execute a specified method of a class in an ‘External Assembly’, then “any assembly that you choose a script from … must also be in the global assembly cache (GAC) for Test Map to function correctly”. You need to GAC your external assemblies before running the unit tests. GAC —> Yuck!
Microsoft’s Integration Roadmap clearly shows a measured commitment to and place for BizTalk in the future, alongside their Azure Platform as a Service (PaaS) technologies. With the pending release of BizTalk 2016 as a drop-in replacement for BizTalk 2013 R2 (with no code recompilation required!), I thought it was time to refresh the practice of unit testing BizTalk Maps.
The Solution
The open source ChannelAdam Test Framework Library for BizTalk addresses all of these issues and provides the following benefits and features:
- Works with BizTalk 2010 / 2013 / 2016
- Never again set the project property “Enable Unit Testing” to “True”!
- BizTalk Map unit tests can be executed against a release build
- The provided map tester classes allow you to easily unit test both XML and flat file BizTalk Maps
- The design of tester classes follow the clean Arrange-Act-Assert (AAA) testing pattern
- Support for arranging the input and expected output from a string, XElement, an XML serialisable object or loading from an embedded resource
- Performs schema validation of both the input and output by default (easily overridable)
- Support for mocking External Assembly class methods
- Support for filtering assertions of the expected output to allow for dynamic data (such as timestamps or GUIDs)
- Detailed information is provided allowing you to see the differences between the expected output and the actual output of the map.
With this library you now have the tools needed to easily unit test you BizTalk Maps using modern testing practices. No excuses!
For information on how to get started, please see the usage documentation.
comments powered by Disqus