FunctionStarted Event

Occurs when a TestFunction starts execution.

Type: Runner

Namespace: XJTAG.Integration.XJRunner

Syntax

public event EventHandler<FunctionStartedEventArgs> FunctionStarted

Example

In this case we subscribe to the FunctionStarted event of a Runner object and give an example of how the FunctionStartedEventArgs object is used to extract information from the event.

class Testing
{
    Runner runner;
    TestCollection testList;

    TestFunction startedFunction;
    string startedFunctionName;
    string startedFunctionTestGroupName;

    void InitialiseRunner()
    {
        /*
         * ...
         * Code to obtain Runner object from project and get test list.
         * ...
         */

        // Subscribe to FunctionStarted event.
        runner.FunctionStarted += runner_FunctionStarted;

        // Run tests.
        runner.RunTests(testList);
    }

    void runner_FunctionStarted(object sender, FunctionStartedEventArgs e)
    {
        // We use the FunctionStartedEventArgs to retrieve information on the function that has
        // been started.

        // Get the TestFunction which was started.
        startedFunction = e.Function;

        // Get the name of the TestFunction that was started and the TestGroup it belongs to.
        startedFunctionTestGroupName = e.Function.TestGroup.Name;
        startedFunctionName = e.Function.Name;
    }
}