Forum Discussion

lalit_singh's avatar
lalit_singh
Contributor
2 years ago

Conditional execution of test case based on whether first test case pass

Conditional execution of test case based on whether first test case pass

 

In my application there is one test case and if gets the required data , rest of the test cases can then only be executed

as they rely on output of first test case

How can apply this in test complete that if first test case shows no data , rest of test cases are bypassed in script 

  • You could create an OnLogError step to check for that TestCase Name and then stop the test runner. The test case name comes from your Execution Plan in TestComplete. You could try something like:

     

    function EventControls_OnLogError() {
      if (equal(aqTestCase.CurrentTestCase.Name, "TestCase1")) {
        Runner.Stop();
      }
    }

     

     

    Are you using ci/cd pipelines to execute your tests? Another solution may be needed in the event you are using Azure pipelines, because you lose control of the onError behavior in this instance.

  • Hi,

     

    Alternatively, you can make dependent tests to be children of this first test in Execution Plan in TestComplete and set OnError property for the first test to 'Stop current item'. All children tests will be skipped if the first test ends with an error.

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Alternatively, you can make dependent tests to be children of this first test in Execution Plan in TestComplete and set OnError property for the first test to 'Stop current item'. All children tests will be skipped if the first test ends with an error.

     

  • Kitt's avatar
    Kitt
    Regular Contributor

    You could create an OnLogError step to check for that TestCase Name and then stop the test runner. The test case name comes from your Execution Plan in TestComplete. You could try something like:

     

    function EventControls_OnLogError() {
      if (equal(aqTestCase.CurrentTestCase.Name, "TestCase1")) {
        Runner.Stop();
      }
    }

     

     

    Are you using ci/cd pipelines to execute your tests? Another solution may be needed in the event you are using Azure pipelines, because you lose control of the onError behavior in this instance.