Forum Discussion

Finan's avatar
Finan
Frequent Contributor
14 years ago

[Resolved] Script to run all testSuite.tearDownScripts

Hi,

I have a project which contains multiple testSuites, of which each testSuite has a tearDownScript.
I want to create a groovy script which can run the tearDownScripts of all other testSuites. (See code below)
However, I receive the following error:

groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestSuitePro.runTearDownScript() is applicable for argument types: () values: [] Possible solutions: runTearDownScript(com.eviware.soapui.model.testsuite.TestSuiteRunContext, com.eviware.soapui.model.testsuite.TestSuiteRunner), getTearDownScript(), setTearDownScript(java.lang.String)

Any idea how to solve this?

project = testRunner.getTestCase().testSuite.getProject()
count = project.getTestSuiteCount()

log.info count

for( int i = 0; i < count; i++)
{
log.info i;
log.info project.getTestSuiteAt(i).name;
b = project.getTestSuiteAt(i)
b.runTearDownScript();
}
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello!

    The error message says that there is no method runTearDownScript(), and suggests that you might have meant to use the method runTearDownScript( TestSuiteRunContext, TestSuiteRunner ).

    You're script might be invoked with these variables -- it depends on where you're script is placed. You want to do something like this:
    project = testRunner.getTestCase().testSuite.getProject()
    count = project.getTestSuiteCount()

    log.info count

    for( int i = 0; i < count; i++)
    {
    log.info i
    log.info project.getTestSuiteAt(i).name
    b = project.getTestSuiteAt(i)
    b.runTearDownScript( context, testRunner )
    }


    Regards!

    /Henrik
    eviware.com
  • Finan's avatar
    Finan
    Frequent Contributor
    I run the teardownscript from a script in a testCase

    your suggestion returned:

    groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestSuitePro.runTearDownScript() is applicable for argument types: (com.eviware.soapui.impl.wsdl.panels.support.MockTestRunContext, com.eviware.soapui.impl.wsdl.panels.support.MockTestRunner) values: [[RunCount:0, log:org.apache.log4j.Logger@7694a5ca, ThreadIndex:0], com.eviware.soapui.impl.wsdl.panels.support.MockTestRunner@1910ad98] Possible solutions: runTearDownScript(com.eviware.soapui.model.testsuite.TestSuiteRunContext, com.eviware.soapui.model.testsuite.TestSuiteRunner), getTearDownScript(), setTearDownScript(java.lang.String)
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    You will need to alter the script a bit, try this:


    import com.eviware.soapui.impl.wsdl.panels.support.MockTestSuiteRunner
    import com.eviware.soapui.impl.wsdl.panels.support.MockTestSuiteRunContext

    project = testRunner.getTestCase().testSuite.getProject()
    count = project.getTestSuiteCount()

    log.info count

    for( int i = 0; i < count; i++)
    {
    log.info i
    log.info project.getTestSuiteAt(i).name
    b = project.getTestSuiteAt(i)
    mockRunner = new MockTestSuiteRunner( b )
    mockContext = new MockTestSuiteRunContext( mockRunner )
    b.runTearDownScript( mockContext, mockRunner )
    }


    Regards,
    Dain
    eviware.com
  • Finan's avatar
    Finan
    Frequent Contributor
    Hi,

    Thanks for the script, it works perfectly