DotNetUnitTestCallMethod Function

Action

This method can be used to call a test method on a valid unit test object. The object needs to be loaded with DotNetUnitTestLoadObject in order to perform all actions that the execution engine of a unit testing framework. DotNetUnitTestLoadObject gathers all information about special Initialize(SetUp) and Cleanup (TearDown) methods that will be called right before and right after the test method.

The supported unit testing frameworks are:

  • Silk Performer .NET Framework

  • NUnit Test Framework

  • Microsoft's unit testing framework (Microsoft Visual Studio 2013, 2015, 2017)

All frameworks offer the functionality of those Initialize and Cleanup methods that will be called by this method call if they exist. Furthermore - Ignore and Expected Exception attriutes will also be handled.

Exceptions that will be catched - either expected or not - will be logged to the TrueLog and to the output log file. If Console redirection is enabled - the standard and error console output will also be logged to the TrueLog and respectivly to the .wrt and .err file.

Methods with the Ignore attribute will not be called. DotNetUnitTestCallMethod will raise an error with severity warning.

DotNetUnitTestCallMethod will raise an error if a method throws an unexpected exceptions.

Include file

DotNetAPI.bdh

Syntax

DotNetUnitTestCallMethod( in    hObject     : number,
                          inout sMethodName : string,
                          in    sTimer      : string optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hObject Handle to a .NET Object
sMethodName Method that should be called
sTimer

(optional)

If defined – a custom timer will be generated to measure the creation time of the object. If the Unit Test class defines a SetUp and/or TearDown method, additional measures will be generated for these additional method calls. The measure name will be {sTimer}_SetUp and {sTimer}_TearDown.

Example

dcltrans
  transaction TMain
  var
    hObject : number;
  begin
    DotNetSetOption(DOTNET_OPT_REDIRECT_CONSOLE, 1);
    hObject := DotNetUnitTestLoadObject("bin\\Release\\MyDotNet.dll", "MyDotNet.TestClass");
    DotNetUnitTestCallMethod(hObject,"TestMethod");
    DotNetUnitTestFreeObject(hObject);
  end TMain;