Forum Discussion

DanNad's avatar
2 years ago

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:

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

  • rraghvani's avatar
    Champion Level 3

    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.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()