Tuesday, February 20, 2007

BizUnit and Visual Studio Team Suite

To get BizUnit working, download the latest version of BizUnit from gotDotNet. This is version
2.2 at this point.

workspaces.gotdotnet.com/bizunit

Once you install this application (make sure you add the .MSI extension to the file you download). You will need to recompile the bizUnit libraries.



a. Load the BizUnit solution
b. Open the BiztalkSteps project.
c. Open the HostConductorStep.cs file
d. Go to the Execute method and change the credentials to match your environment.



as you can tell the first item is the userID and the second is the password:
creds[0] = "thunderbolt\\administrator";
creds[1] = "1*ehorizon";

e. Now right click on the BiztalkSteps project and rebuild it.
f. Rebuild the Microsoft.Services.BizTalkApplicationFramework.BizUnit project.

This should all be the binaries that you need to run the BizUnit.

Additionally, there are 3 more projects included in the solution:
a. LoadGenSteps
b. MQSeriesSteps
c. OutlookReadStep

For the LoadGenSteps, if you dont have the Load Generation Tool, then when you try to compile the LoadGenSteps project will give you this error:
Error 52 The type or namespace name 'LoadGen' could not be found (are you missing a using directive or an assembly reference?) C:\Program Files\Microsoft Services\BizUnit 2.2\Src\TestStepLibraries\LoadGenSteps\LoadGenExecuteStep.cs 21 7 LoadGenSteps
and this other error:
Error 53 The type or namespace name 'LoadGenStopEventArgs' could not be found (are you missing a using directive or an assembly reference?) C:\Program Files\Microsoft Services\BizUnit 2.2\Src\TestStepLibraries\LoadGenSteps\LoadGenExecuteStep.cs 102 53 LoadGenSteps

To fix this download the LoadGen tool from the Microsoft site. Install it and then recompile.

For the OutlookReadSteps, when you try to compile this project you will get this error:
Error 51 The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?) C:\Program Files\Microsoft Services\BizUnit 2.2\Src\TestStepLibraries\OutlookReadStep\OutlookReadStep.cs 25 35 OutlookReadStep
You can just ignore this for now, since outlook might not be installed on the local machine.

Now we are ready to write unit test against any of the artifacts for Biztalk. Create your Test project and add a reference to the BizUnit assembly:

Microsoft.Services.BizTalkApplicationFramework.BizUnit

On the TestInitialize read the SETUP.XML. Inside each of the TestMethod read the TEST#.XML containing your settings for that particular test.

Your code will look something like this:
using Microsoft.Services.BizTalkApplicationFramework.BizUnit;

[TestInitialize]
public void Setup()
{
// Stopping and Starting BizTalkHostInstance
BizUnit bizUnit = new BizUnit(_PathLocation + "Test_Setup.xml", BizUnit.TestGroupPhase.TestGroupSetup);
bizUnit.RunTest();
}

[TestMethod]
public void ValidateDiscount_Rejected()
{
// Stopping and Starting BizTalkHostInstance
BizUnit bizUnit = new BizUnit(_PathLocation + "Test_1_DiscSystem.xml");
bizUnit.RunTest();
}
For BizUnit to work, it reads the configuration files. Each configuration file will contain the same regions into it:
a. TestSetup
b. TestExecution
c. TestCleanup

[TestInitialize]
this will stop and start the host, to make sure that we are using the latest biztalk assembly. A typical configuration file for the setup will look like this:



[TestMethod]
this is the configuration file that will execute the actual unit test. Noticed that you can use any XPath queries inside the ValidationStep. This XPath queries will be your asserts into the values inside the message.




No comments: