Check Out the Latest News About SmartBear Connect
Occasional Contributor
Posts: 10
Registered: ‎01-11-2017

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?



Posts: 187
Registered: ‎03-17-2016

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