TestingStopped Event

Occurs when a test run is manually stopped by the user. This event is fired from an arbitrary thread. The event will occur before WaitForCompletion returns.

Type: Runner

Namespace: XJTAG.Integration.XJRunner

Syntax

public event EventHandler TestingStopped

Remarks

This event is fired from the thread on which the test code is running. You therefore need to be careful about synchronising access to your data structures and, if your code accesses any user interface controls, you will need to use BeginInvoke to ensure that you access methods and properties from the appropriate thread.

Example

In this example we show how to enable a Windows.Forms.Button control upon the test run being stopped by the user, using the TestingStopped event.

class Testing
{
    Runner runner;
    TestCollection testList;

    Button runButton;

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

        // Subscribe to TestingStarted event.
        runner.TestingStarted += runner_TestingStarted;

        // Subscribe to TestingFinished event.
        runner.TestingStopped += runner_TestingStopped;

    }

    // Disable runButton on testing started.
    void runner_TestingStarted(object sender, EventArgs e)
    {
        runButton.Enabled = false;
    }

    // Enable runButton on testing stopped.
    void runner_TestingStopped(object sender, EventArgs e)
    {
        runButton.Enabled = true;
    }
}