Forum Discussion

pkunst's avatar
pkunst
Contributor
11 years ago

Get Status of test case

Is there a way to look up the test case result of another test case?
I tried to look it up, but it does not work.
def status= testCase.testSuite.project.getTestSuiteByName("Customer TestSuite").getTestCaseByName("TestCase01").testRunner.status

def status= testCase.testSuite.project.getTestSuiteByName("Customer TestSuite").getTestCaseByName("TestCase01").testCaseRunner.status

The script is not in the
If there is no way to look it up I have to save the status in the tear down script into a property and get the value in another script. But that is not a nice way to solve the problem.

3 Replies

  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    I was able to do this by scanning through the assertions. It seems the status of the TC is stored in the testRunner which I am not sure of how you would be able to grab that unless you set up a controller script that runs everything. Only problem with controller scripts is they lock down that script completely and can easily lock up your SoapUI and there is no decent way to cancel them (unless you build in a kill switch).

    Here is the code I used to get the assertion results (mine is a totally different project that I tested with)

    def proj = testRunner.testCase.testSuite.project.getWorkspace().getProjectByName("AutoCreate");
    for (ts in proj.getTestSuiteByName("AutoTest").getTestCaseByName("AutoCreate").getTestStepList()) {
    if (ts instanceof com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep ) {
    for (assertion in ts.getAssertionList() ){
    log.info assertion.getStatus();
    }
    }
    }


    And a sample of the results:

    Mon Feb 17 06:18:52 MST 2014:INFO:VALID
    Mon Feb 17 06:18:52 MST 2014:INFO:VALID
    Mon Feb 17 06:18:52 MST 2014:INFO:FAILED
    Mon Feb 17 06:18:52 MST 2014:INFO:UNKNOWN
    Mon Feb 17 06:18:52 MST 2014:INFO:UNKNOWN
    Mon Feb 17 06:18:52 MST 2014:INFO:UNKNOWN
    Mon Feb 17 06:18:52 MST 2014:INFO:UNKNOWN
  • Thank you. I wil try it.
    It is a smarter way to go through it than I my solution.
  • Your solution is working fine for normal TestSteps, which have assertions.
    The problem is, that, if a script or a property transfer fails, the script will not notice.
    I did it that way:
    testCase.setPropertyValue("testCaseStatus", testRunner.status.toString())

    The code above I run in the TearDown Script of a TestCase.
    If I want to know if the TestCase failed or not I can read out the property.
    This also works if scripts or propertytransfers failed.