Forum Discussion

Player433's avatar
Player433
New Contributor
14 years ago

AssertionList Issue

I have a groovy script that basically goes through every test step in a test case and displays a report of all assertions of each test step.

I recently introduced database validations in a test case and becuase of the properties file and groovy scripts that were added, they are failing my groovy test step.

def project = testRunner.testCase.testSuite.project
def testCase = testSuite.getTestCaseByName(project.getPropertyValue("TestCase"))
testCase.run(null, false)

for(testStep in testCase.getTestStepList()){
assertList = testStep.getAssertionList() <- testStep does not have method "getAssertionList()"
for(assertItem in assertList){
logSaver(testStep.getName() + " - Assertion :" + assertItem.getName() + "--" + assertItem.getStatus())
error = assertItem.getErrors()
if (error != null){logSaver(error[0].getMessage())}
}
}


Ultimately the problem is that I have other test step types in my test case, but I don't know how to figure out what kind of test step I have.

If I knew of a command that could identify what type of test step I have, then this would be done.

Thanks
  • Player433's avatar
    Player433
    New Contributor
    I finally figured out the answer to my question.

    I should've looked at the API's a little more thoroughly but I also found some other forum post that gave me an idea.

    for(testStep in testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.class)){
    assertList = testStep.getAssertionList()
    for(assertItem in assertList){
    logSaver(testStep.getName() + " - Assertion :" + assertItem.getName() + "--" + assertItem.getStatus())
    error = assertItem.getErrors()
    if (error != null){logSaver(error[0].getMessage())}
    }
    }