Ask a Question

Is it possible to mark test as failed when jscript exception occurs?

DanNad
Occasional Contributor

Is it possible to mark test as failed when jscript exception occurs?

Currently i have a problem that some of my tests are falsly marked as passed when jscript exception occurs. This is just an log example but when my tests fail it looks similar:

DanNad_0-1660305684630.png


Is it possible to check for exception count (not Log.Error count) and when OnStopTest Event is executed to mark the test as failed?
Is there a global counter for exceptions in testcomplete or if not is it possible to make a global variable / project.variable ?

1 REPLY 1
rraghvani
Regular Contributor

If your project properties is configured to "Stop current item" on "On Error",

 

function testit()
{
    try {
    	// Cause an exception to occur
        throw new Error("An exception has occurred");
    } catch (e) {
    	// Perform cleanup
        Log.Message("Catch Perform Cleanup");

    	// Log error message
    	Log.Error(e.message);
        
        Log.Message("This should not be called");
    } finally {
    	// Perform cleanup
        Log.Message("Finally Perform Cleanup");
    }

    Log.Message("This should not be called as well");
}

 

Then both messages e.g. "This should not be called..." will not be shown, as TestComplete will stop at Log.Error()

cancel
Showing results for 
Search instead for 
Did you mean: