Forum Discussion

Apoorva6's avatar
Apoorva6
Frequent Contributor
8 years ago
Solved

How to stop testSuite with many TestCases even if one test step in any testCase fails?

Hi, is there a way to stop whole test Suite even if any testStep fails in any TestCase ?

 

I have one test suite which has 3 Test cases. Each test case has many test steps and in all test steps, I am using contains assertion. As of now if any assertion fails , only that TestCase fails, but I want to stop whole test suite if any test step in any test case fails immediately. Please help me if it is doable with script assertion and if so how exactly ?

  • As far as I know there is no out-of-the box setting which you could simply use. You can use the following workaround:

     

    Set a SetUp script for your test suite:

    testSuite.setPropertyValue("TestSuiteResult", "OK")

     

    For each of your test cases within the suite set a:

    - SetUp script: 

    assert (testCase.testSuite.getPropertyValue("TestSuiteResult") != "FAILED")

    - TearDown script:

    if (testRunner.getStatus().toString() == "FAILED") {
      testCase.testSuite.setPropertyValue("TestSuiteResult", "FAILED")
    }

    These scripts stop the execution of the next test case if one test case fails.

     

    For each of your test cases also switch on the option "Abort On Error". You can do that in a test case editor. The test case will stop with a first test step failure.

     

    Just a comment:

    A test suite has a method setAbortOnError(bolean) in the SoapUI API, however if you set this property to true, it does not prevent execution of the next test case if a test case fails. 

     

4 Replies

  • KarelHusa's avatar
    KarelHusa
    Champion Level 3

    As far as I know there is no out-of-the box setting which you could simply use. You can use the following workaround:

     

    Set a SetUp script for your test suite:

    testSuite.setPropertyValue("TestSuiteResult", "OK")

     

    For each of your test cases within the suite set a:

    - SetUp script: 

    assert (testCase.testSuite.getPropertyValue("TestSuiteResult") != "FAILED")

    - TearDown script:

    if (testRunner.getStatus().toString() == "FAILED") {
      testCase.testSuite.setPropertyValue("TestSuiteResult", "FAILED")
    }

    These scripts stop the execution of the next test case if one test case fails.

     

    For each of your test cases also switch on the option "Abort On Error". You can do that in a test case editor. The test case will stop with a first test step failure.

     

    Just a comment:

    A test suite has a method setAbortOnError(bolean) in the SoapUI API, however if you set this property to true, it does not prevent execution of the next test case if a test case fails. 

     

  • nmrao's avatar
    nmrao
    Champion Level 3
    It appears that there is dependency between the tests. It is good practice that each test should be independent of others.
    What is the problem if the following tests run, let them fail.
    • saprao's avatar
      saprao
      Occasional Contributor
      Hi, I have same query...please anyone help me. Same like above scenario my test suite contains with many test cases ... and validating one test step soap response assertion. if assertion is fails then stop then entire test suite. it is working fine for test case level but it' won't stop other test cases. Thanks