SmartBear Connect 2018
Join us at SmartBear Connect 2018 on October 29th & 30th in Boston, MA.
Apply to speak and share your experience with the greater SmartBear Community
Occasional Contributor

SoapUI API - Create Requirements Through Groovy Error

[ Edited ]

After my previous thread with SoapUI requirements I've moved on to trying to add them to the project programmatically.  There is only one method available in Class WsdlProjectRequirements for adding a requirement. It accepts a String for the ID and a Test Case object (com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase testCase).  


However, I'm not sure what it is actually wanting as whenever I try to send in a Test Case object (I'm using Pro so this is obviously a Test Case Pro object) I get an exception, see attached.  


How can I send it a WsdlTestCase when I'm using SoapUI Pro?  Or is there another way to go about this besides importing a file of requirements?




Re: SoapUI API - Create Requirements Through Groovy Error

[ Edited ]

Hi Nick,


According to Class WsdlProjectRequirements a requirement should be added to WsdlProjectRequirements (not to WsdlProject). To get it, you need to use context.getTestCase().getTestSuite().getProject().getRequirements().

So, to add the requirement to a testCase, you can use the following script: 


def project = context.getTestCase().getTestSuite().getProject();
def testCase = context.getTestCase()
def requirements = project.getRequirements()

requirements.addRequirement("ID", testCase)
Customer Care Team