Forum Discussion

groovyguy's avatar
groovyguy
Champion Level 1
6 years ago

Script Challenge - Assertions Statuses and Messages

Here's my contribution to the Script challenge issued, specifically for logging all of the assertions across a test suite.

 

import com.eviware.soapui.support.xml.XmlUtils;

def p = context.testCase.testSuite.project;

	for(s in p.testSuiteList)
	{
		log.info("----------------------" + s.getLabel() + "------------------------");
		for(c in s.testCaseList)
		{
			log.info("------" + c.getLabel() + "---------");
			for(st in c.testStepList)
			{
				log.info("---" + st.getLabel() + "---");
				if (st instanceof com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep) 
				{
					log.info("-------------------------------------------------");
					def assertions = st.getAssertionCount();
					for (int i = 0; i < assertions; i++)
					{
						def assertion = st.getAssertionAt(i);
						log.info(assertion.getLabel() + " " + assertion.getStatus() + " " + assertion.getErrors());
					}
				}
			}
		}
	}

 

 

1 Reply

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Awesome! I've added the Techcorner label to your topic. Feel free to use this label when you post any interesting and useful samples or How To topics. Thanks!