Test Methods

When the Code Generation Engine scans the .NET assembly and finds a method with a TestMethod attribute, the engine scripts a call to the method in the current transaction. The current transaction is the transaction method that was declared before the test method. As a result, declaring a test method without a transaction method results in an error. Declaration means that the transaction method has been declared previously in the code.

Test Method

C# Code BDL Script
[Transaction(Etranstype.TRANSTYPE_MAIN)]
public void TMain1()
{
}

[TestMethod]
public void TestMeth1()
{
}

[Transaction(Etranstype.TRANSTYPE_MAIN)]
public void TMain2()
{
}

[TestMethod]
public void TestMeth2()
{
}

[TestMethod]
public void TestMeth3()
{
}
dcltrans
  transaction TMain1
  begin
    DotNetCallMethod(hVuser1, "TMain1");
    DotNetCallMethod(hVuser1, "TestMeth1");
  end;
  transaction TMain2
  begin
    DotNetCallMethod(hVuser1, "TMain2");
    DotNetCallMethod(hVuser1, "TestMeth2");
    DotNetCallMethod(hVuser1, "TestMeth3");
  end;

Erroneous Test Method Declaration

The following test method declaration would cause an error with the Code Generation Engine as there is no current transaction for the TestMeth1 method:
[TestMethod]
public void TestMeth1()
{}

[Transaction(Etranstype.TRANSTYPE_MAIN)]
public void TMain1()
{}