Forum Discussion

jnickgo's avatar
jnickgo
Occasional Contributor
8 years ago

SoapUI API - Create Requirements Through Groovy Error

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?

 

 

  • Nastya_Khovrina's avatar
    Nastya_Khovrina
    SmartBear Alumni (Retired)

    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)