Access Requirements Programmatically
Hello,
I've been researching the Ready! API requirements management features a bit lately. It seems like I could get some use out of them if I was able to report better on them.
Initially what I wanted to do was to added requirements to several test cases and then after executing the Test Runner to review the report.xml or {test-suite}.xml and be able to see the requirement coverage as it relates to the test cases. It does not seem that this information is passed on at all to the JUnit .xml reports. If I created a custom property and then entered the requirement information there then that information would appear in the JUnit .xml report as shown below.
<testcase name="TestCase 1" time="0.121"> <properties> <property name="requirements" value="4003,4002"/> </properties> </testcase>
The problem is how to get it there. Can I access any of the requirements information programmatically, for instance through a Groovy script? I have not seen any example of this and have not been able to so far.
Any help with this would be welcome.
Thanks!
Hi Nick,
Thank you for your post. You can use the following groovy script (in a groovy TestStep) to access TestCase requirements:
def project = context.getTestCase().getTestSuite().getProject(); def requirements = project.getRequirements().getRequirementsList() for (requirement in requirements){ log.info requirement.getId() log.info requirement.getName() log.info requirement.getDescription() }
Refer this documentation for details:
https://www.soapui.org/apidocs/pro/com/eviware/soapui/impl/wsdl/WsdlProjectPro.html
https://www.soapui.org/apidocs/pro/com/eviware/soapui/impl/wsdl/project/WsdlProjectRequirements.html