Forum Discussion

krogold's avatar
krogold
Regular Contributor
7 years ago

Groovy assert called test step's result

 Hello,

 

I have a problem with groovy scripts when I call a testStep. I proceed as follows :

 

def TC; 
def async = false

TC = testRunner.testCase.testSuite.project.getTestSuiteByName(testSuite).getTestCaseByName(testcase)

TC.setPropertyValue("my_prop", my_value)
result = TC.run (context.getProperties(), async)      

log.info result.status

the logger indicates PASS

 

the problem is when I try to assert this status (which is an enum), assertion always fails

 

assert result.status == "PASS"  => fails
assert result.status == PASS  => not authorized

how could I do ?

 

thanks for any help

 

Alexandre

 
 
 
  • Hi,

     

    You can parse the result status as a String and then compare it like:

     

    assert String.valueOf( result.status ).equals("PASS")

    Cheers! :smileyvery-happy:

  • Lucian's avatar
    Lucian
    Community Hero

    Hi,

     

    You can parse the result status as a String and then compare it like:

     

    assert String.valueOf( result.status ).equals("PASS")

    Cheers! :smileyvery-happy: