jeudi 23 mai 2019

How to exit a running unit test programmatically (with Visual Studio c#, and unit test framework)

If I have an automated test that is currently executing, I need the automation to exit if it runs into a problem, such as a network stoppage or when the System Under Test (SUT) is down.

If I try to Assert.Inconclusive("some message"), it doesn't handle the exception gracefully. I want the framework to log the info to the logger, exit the test gracefully, and go on to the next test.

Has anyone dealt with this issue? I need it to do something like this -- (the driver is the Chrome WebDriver (selenium)).

// ---- check for services down warning  -----
        bool isDown = await CheckForServicesWarning(driver);
        if (isDown == true)
        {
            Log("XYZ is currently experiencing technical difficulties.");
            return;
        }

Aucun commentaire:

Enregistrer un commentaire