Home

TUnit


Invoke .NET assembly library members for Unit Test.
NUnit is famous framework that run test case inside a dll for testing a methods on dll target. TUnit is simply utility that invoke directly methods to test on dll target.
As you see on the bitmap we have a dll ..\..\..\ClassLibrary1.dll with a class ClassLibrary1.Class1 , one property MyProperty, and two methods MethodtoTest() MethodtoTest2().
First, you must browse dll NET assembly to test with ildasm (utility deploied with Framework SDK) or ObjectBrowser of Visual Studio.
Second, write a xml structure like a bitmap that describe a methods and properties to test (TUnit create for you a template from Other->Make a test template).
Third, run Tunit that load a xml and show you a tree view with testset.
Four, run the TestSet, methods will be execute and html report or txt report with return values will be showed.
TUnit, for the moment, support primitive type (int, short, long, string and int[], short[], long[], string[]).

Syntiax for describe a method with a sign:

public bool MethodToTest2(string stringToAddToArray, int intToAddToArray, string[] stringArray, int[] intArray)
{...}

...
<Method Name="MethodToTest2" ReturnType="bool" Comment="Comment123">
 <Params>
  <Param Name="stringToAddToArray" Type="string" Value="zzz" />
  <Param Name="intToAddToArray" Type="int" Value="22" />
  <Param Name="stringArray" Type="string[]" Value="val1,val2,val3" />
  <Param Name="intArray" Type="int[]" Value="4,5,6" />
 </Params>
</Method>
...

You can note how you can describe a array.
Editing xml you can validate it using IE Validate TestSet from Other menù.

TUnit VS. NUnit

NUnit test case method on NUTestCase.dll Target test method on TargetTest.dll TUnit test case method on TUTestCase.dll
NUnit GUI load all method with attribute [Test] on NUTestCase.dll, run it,
and display result of method Assert.AreEqual().
Target test method invoke from TestCaseMethod1(). TUnit invoke TestCaseMethod1() on TUTestCase.dll
that call Method1() on TUTestCase.dll passing some parameters.
[Test]
public void TestCaseMethod1()
{
 TargetTestDll.Class1 ttd = new TargetTestDll.Class1();
 bool ret = ttd.Method1("Hello",15);
 Assert.AreEqual(true, ret);
}
public bool Method1(string str, int i)
{
 if (str = = "Hello" && i = = 15)
  {return true;}//do some work
 else
  {return false;}
}
public bool TestCaseMethod1(string str, int i)
{
 TargetTestDll.Class1 ttd = new TargetTestDll.Class1();
 bool ret = ttd.Method1(str,i);
 return ret;
}

Test case NUnit methods are methods without parameters, you must make one test case for each value you want pass to method to test.With TUnit you can run test case with parameters.

System requirement: Windows XP SP2, Framework 2.0











Home
Up