Using BizUnit with Visual Studio


Hi everyone,


In the last blog that I did (here) I wrote a short description on how to use LoadGen 2007 to perform a simple Load Test on your BizTalk solution using the FileTransport. In this blog I would like to setup a simple test using BizUnit. If you are already familiar with Unit Testing then you will most likely see the benefits this can provide for your BizTalk environment. There are several different versions of BizUnit. The newest version can be found at www.codeplex.com/BizUnit. For my test I am using version 2.3 (at the time of this writing 3.0 was ready however I was getting Assembly errors while using Visual Studio 2005 so I switched to 2.3). I tested with Visual Studio 2005, BizTalk 2006 R2 and BizUnit 2.3.


STEP 1. Install BizUnit www.codeplex.com/BizUnit (if you check http://bizunit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29779 you will see that there are various versions that you can download depending upon your needs)


install directory is %Program Files%\BizUnit\BizUnit 2.3 under this new folder there will be 2 subfolders containing:



  1. Bins folder, containing DLL's that you will need to build you BizUnit tests.

  2. Src folder, containing source code and examples.

STEP 2. Open your Visual Studio 2005 BizTalk Project and add new project to your solution (make sure you choose C# > Test if that is what you wish otherwise you will get default VB > Test)


Besides the usual Properties and References folders you should also see the following files:



  1. AuthoringTests.txt, contains a short description of how to create, run and view test results.

  2. ManualTest1.mht, a template file to aid you if you need to do manual tests as part of your testing regimen. You may remove this if you do not wish to run manual tests.

  3. UnitTest1.cs

STEP 3. In your new Test project add a reference to %Program Files%\BizUnit\BizUnit 2.3\bins\Microsoft.Services.BizTalkApplicationFramework.Bizunit.dll


Create a reference in your VS Test project to the BizUnit dll.



  1. Right click references

  2. browse to where ever your BizUnit is installed, in my case that is: %Program Files%\BizUnit\BizUnit 2.3

  3. add a reference to Microsoft.Services.BizTalkApplicationFramework.BizUnit.dll

STEP 4. Create a Test Case. 


  1. Open UnitTest1.cs or create your own new class, we want to create a reference via an 'using' statement in order to invoke the BizUnit functionality.

  2. VS creates several 'using' references for you already however you will need to add: using Microsoft.Services.BizTalkApplicationFramework.BizUnit;

  3. your class needs the attribute [TestClass] though most likely VS has added this for you already.

  4. now we should also see a Constructor and a default test method (assuming you are using the Default UnitTest1.cs they will be UnitTest1 and TestMethod1 respectively).

  5. I recommend now added a folder to your project called TestCases. There is a wizard that we can use to create tests but lets' keep it simple first.

  6. Right Click folder TestCases and add an XML file called TESTCASE01.xml

  7. Add the following text to the new XML file:

* in this test we are creating 3 separate files Request01.xml, Request500.xml and Request501.xml from your creation folder and dropping them into a File Folder directory which is also the file pickup up point for an endpoint configured (this could be an UNC path) on your BizTalk Solution.






    <TestCase testName="TESTCASE01">

     <TestSetup> </TestSetup>
     
     <TestExecution>

      <TestStep assemblyPath="" typeName="Microsoft.Services.BizTalkApplicationFramework.BizUnit.FileCreateStep"> 
       <SourcePath>%YourPath%\TestCases\Request01.xml</SourcePath>
       <CreationPath>%YourPath%\Filedrop\ReceiveRequest\Request01.xml</CreationPath>
      </TestStep>

      <TestStep assemblyPath="" typeName="Microsoft.Services.BizTalkApplicationFramework.BizUnit.FileCreateStep">
       <SourcePath>%YourPath%\TestCases\Request500.xml</SourcePath>
       <CreationPath>%YourPath%\Filedrop\ReceiveRequest\Request500.xml</CreationPath>
      </TestStep>

      <TestStep assemblyPath="" typeName="Microsoft.Services.BizTalkApplicationFramework.BizUnit.FileCreateStep">
       <SourcePath>%YourPath%\TestCases\Request501.xml</SourcePath>
       <CreationPath>%YourPath%\Filedrop\ReceiveRequest\Request501.xml</CreationPath>
      </TestStep>

     </TestExecution>
     
    </TestCase>


  1. Open the UnitTest1.cs and add the following code to public void TestMethod1():






  2. BizUnit biz = new BizUnit(@"..\..\..\<YourSolution>\TestCases\TESTCASE01.xml"); //this path depends where you have placed the XML testcase file. 
    biz.RunTest();



STEP 5. Run the Test (Choose Menu > Test > Start Selected Test Project with/without Debugging)


STEP 6. View the Results.


Skip to main content