I've released BizUnit 2.0, in case you’ve not come across it before, BizUnit is a framework that I put together to enable the rapid development of automated functional testing for BizTalk solutions, the motivation was to provide a framework that would bring automated testing of BizTalk solutions to the masses!! BizTalk solutions are often mission critical, an automated testing approach helps to drive quality before go-live and is essential post go-live to ensure that patches to not cause regressions. BizUnit is not restricted to testing BizTalk solutions, but it is targeted at them.

 

BizUnit defines test cases as Xml documents, which, enables test cases to be rapidly written and also enables the same test cases to moved between different environments by fixing up the Url’s for the endpoints, for example the endpoint Url’s for a development environment will be different to a testing, and pre-production environments.

 

Also, by having the test cases defined as Xml, it allows them to be easily generated, some of the customers that I have worked with define their test matrixes in Excel, and then auto-generate the BizUnit test cases from Excel.

 

Test Case Format

A test case is made up of three stages, test setup, test execution and test cleanup, the cleanup stage is always executed and intended to leave the platform in the same state that it started.

 

Each stage may consist of zero or more test steps, test steps are in general autonomous, state can be flowed between them if required using the ‘context’ object that is passed to each test step.

  

 

How does it Work?

BizUnit takes a black box approach to testing BizTalk solutions, if you look at the scenario below, a BizTalk solution receives a request-response message over HTTP, the message is routed to an Orchestration which, sends a message to MSMQ and another to a FILE drop, the Orchestration waits for a FILE to be received, after which the Orchestration sends the response back to the waiting HTTP client. The solution also uses BAM, writing business data to the BAM database.

 

In order to test this scenario, a BizUnit test case is defined that has 5 test steps:

  1. The HttpRequestResponseStep sends the request to the two-way receive port and waits for the response. This step is executed concurrently so that the other test steps may execute whilst it waiting for the response
  2. The MSMQReadStep waits for a message to appear on an MSMQ queue, when it reads the message it uses the XmlValidationStep to perform schema validation and also execute a number of XPath expression to ensure the message contains the correct data
  3. The FileValidateStep waits for a FILE to be written to a given directory, when it reads the FILE it validates the data using the RegExValidationStep validation step since the FILE picked up was a flat file format
  4. The FileCreateStep creates a new FILE in the specified directory containing the data that the backend system would typically create. This allows the Orchestration to complete and send the response back to the waiting HttpRequestResponseStep step
  5. Finally, DBQueryStep is used to check that all of the BAM data has been successfully written to the BAMPrimaryImportDB 

 

BizUnit 2.0 Enhancements

A number of enhancements have been added to BizUnit 2.0, firstly, there are now some 37 test steps, which is vastly improved from the previous version. A lot of people have contributed test steps which I’ve included in this version. Briefly, here’s some of the enhancements:

  • Concurrent test step execution option – allows multiple test steps to be executed at once
  • Context – allows state to be flowed between test steps, think of the scenario where a FILE is written the content of which specifies where the response should be written
  • Test group setup / tear down stages  - allows group wide setup and cleanup
  • Help – all of the test steps have help in a .chm (accessed from Program Files\Microsoft Services BizTalkApplicationFramework\BizUnit 2.0\Documentation. The help contains Xml configuration examples for each test step that can be copy/pasted into a test case, along which a description of each configuration option etc
  • FailOnError – flag to allow failed test cases to be ignored, this is useful during the cleanup stage 

Here’s a list of all of the test steps in BizUnit build 2.0.1062.0, the documentation provides more details around what these steps do and how to use them:

BAMDeploymentStep

CheckPop3MailStep

ContextManipulatorStep

CrossReferenceDataVerificationStep

CrossReferenceSeedClearStep

CrossReferenceSeedLoadStep

DatabaseDeleteStep

DatabaseRowCountStep

DBQueryStep

DelayStep

DotNetObjectInvokerStep

EventLogCheckStep

EventLogClearStep

ExecuteCommandStep

FileCreateStep

FileDeleteMultipleStep

FileDeleteStep

FileMoveStep

FileMultiValidateStep

FilesExistStep

FilesMoveStep

FileValidateStep

HttpPostStep

HttpRequestResponseStep

MSMQCreateQueueStep

MSMQDeleteQueueStep

MSMQQueuePurgeStep

MSMQReadStep

MSMQWriteStep

OrchestrationConductorStep

ReceiveLocationEnabledStep

ReceivePortConductorStep

RenameDirectoryStep

RuleEngineStep

SMTPReadStep

SOAPHTTPRequestResponseStep

WaitOnFileStep

MQSeriesClearQueueStep

MQSeriesGetStep

MQSeriesPutStep

OutlookReadStep

 

Validation Steps:

BinaryValidationStep

ContextValidationStep

RegExValidationStep

XmlValidationStep

  

Context Loader Steps:

RegExContextLoader

TextContextLoader

XmlContextLoader

 

Test Coverage:

So, you’ve developed all of your BVT’s (Build Verification Tests) for your BizTalk solution using BizUnit, how do you know whether you’ve done a good job, and how much test coverage you have? Enter Jason Births “Orchestration Profiler”. This is a great tool that you can use in conjunction with BizUnit to ensure that you have adequate test coverage, it produces a detailed graphical report of what the test coverage is like, I highly recommend using it with BizUnit.

 

 

Finally, I’d like to give my special thanks to a number of people that have contributed test steps, requirements and ideas for BizUnit 2.0, my apologies if I have missed off anyone, it’s not intentional just my disorganisation!, please let me know if that is the case:

 

Dave Regan

Tanveer Rashid

Daren Jefford

Kevin Purcell

Karina Apostolides

Jon Bonnick

Brian Milburn

Rahmatullah Khan

 

Future work:

A couple of the guys above have done some great work building a Visual Studio plugin for BizUnit and a command line driver. I didn’t have time to get it in this release, but it’ll be following soon. If you find any bugs, or have test steps you'd like to contribute please sned them along to me and I'll get them into the next drop.

 

Enjoy!