Forum Discussion

Rookie's avatar
Rookie
Occasional Contributor
9 years ago

Would like to run another TestCase using Groovy

Hi,

 

I'm totally new to this.  I am trying to Execute another TestCase using Groovy.  For some reason this code is not working for me.  I am using ReadyAPI 1.6.0:

 


//get test case from other project or from the same one
project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("ProjectName")
testSuite = project.getTestSuiteByName("TestSuiteName");
testCase = testSuite.getTestCaseByName("TestCaseName");
/*
//set properties if you need
testRunner.testCase.setPropertyValue(property_name, property_value);
testRunner.testCase.setPropertyValue(another_property_name, another_property_value);
*/
// run test case
runner = testCase.run(null, false); //new com.eviware.soapui.support.types.StringToObjectMap()

  • What error are you getting? This is the code that I use to call another test case from within the same test suite:

     

    import com.eviware.soapui.support.types.StringToObjectMap
    
    def testCase = testRunner.getTestCase().getTestSuite().getTestCaseByName('Test Case Name')
    testCase.setPropertyValue('Proprety Name', 'Property Value')
    testCase.run(new StringToObjectMap(), false)

     

    This looks very close to your code...

  • Radford's avatar
    Radford
    Super Contributor

    What error are you getting? This is the code that I use to call another test case from within the same test suite:

     

    import com.eviware.soapui.support.types.StringToObjectMap
    
    def testCase = testRunner.getTestCase().getTestSuite().getTestCaseByName('Test Case Name')
    testCase.setPropertyValue('Proprety Name', 'Property Value')
    testCase.run(new StringToObjectMap(), false)

     

    This looks very close to your code...