Forum Discussion

Awesome's avatar
Awesome
Frequent Contributor
17 years ago

Outputting results to html file

so i have this bit of code (thanks to this nice forum!) that grabs the results from each teststep and outputs a nice table to results.html:

for( r in testRunner.results ){ 
  i++;
  if (r.status.toString() == "OK") step_a = step_a + "" + i + " - '" + r.testStep.name + "' finished with status " + "" + r.status + "\n" ;
  else if (r.status.toString() == "FAILED") step_a = step_a + "" + i + " - '" + r.testStep.name + "' finished with status " + "" + r.status + "\n" ;
}

QUESTION:

how do i grab the results of the assertions for a request from testRunner.results?

Thank you!
  • Awesome's avatar
    Awesome
    Frequent Contributor
    anyone know if this would this work?: r.testStep.name.getAssertionAt

    and then i could use it in a loop to grab the results of each assertion?

    def testStep = testRunner.testCase.testSteps[testStepName]
    for(def i=testStep.assertionCount-1; i>=0; i--) {
      r.testStep.name.getAssertionAt(i));
    }
  • Hi!

    Try this:


    def testStep = testRunner.testCase.getTestStepByName(testStepName)
    for(def i=testStep.assertionCount-1; i>=0; i--) {
      def a = testStep.getAssertionAt(i)
      log.info(a.label+": "+a.status);
    }


    Obviously you can replace the log line and do whatever you want with the assertion, like writing the status to HTML. Hope this helps!

    Regards,
    Dain
    eviware.com