Forum Discussion

AnandKiran's avatar
AnandKiran
Frequent Contributor
16 years ago

How to run the testsuite from another testsuite

Hi Ole,
             From the blogs i learnt how to control the test case execution with groovy. But my issue is i want to do the same thing but for different test suites . Is there a way to do it using groovy if so can you please let me know the process .

Thanks
With Regards
Anand Kiran G
  • Hello!

    In the current verson of soapUI you basically have to run each TestCase in a TestSuite individually:


    def testSuite = testRunner.testCase.testSuite.project.testSuites['Your TestSuite']
    for(testcase in testSuite.testCaseList) {
    //Run your testcase
    }


    However, the upcoming 3.0 version will have an improved API for running TestSuites from Groovy.

    Regards,
    Dain
    eviware support
  • star's avatar
    star
    Occasional Contributor
    I am trying to run this but unable to

    If I am in 'test_suite_1' and want to run a test case named  'get_id' in 'test_suite_2'  how do i do it?  What command do I use to do it? Also how can i pass groovy variable to 'get_id'?

    def testSuite = testRunner.testCase.testSuite.project.testSuites[''test_suite_2']

    Thanks,
  • Hi,


    Retrieve a test case from a test suite like this:

    def testCase = testSuite["get_id"]

    Then you'll need to run the test case runner:

    def runner = new WsdlTestCaseRunner( testCase, new StringToObjectMap() );
    runner.start(false)


    That should help.
    The upcoming soapUI 3.0 will have a nicer API to run tests.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla
  • star's avatar
    star
    Occasional Contributor
    Thanks, but i could not make it work.

    running this  command:
    def testCase = testSuite["get_id"]

    with "get_id" replaced with the test suite i want.

    i get the following error:
    groovy.lang.MissingPropertyException: No such property:testSuite for class:Script32



    If I use this:
    def runner = new WsdlTestCaseRunner( testCase, new StringToObjectMap() );
    runner.start(false)

    I getthe following:

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script35.groovy: 35: unable to resolve class WsdlTestCaseRunner @ line 35, column 14.org.codehaus.groovy.syntax.SyntaxException: unable to resolve class WsdlTestCaseRunner @ line 35, column 14. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:113) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:218) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:228) at org.codehaus.groovy.control.ResolveVisitor.transformConstructorCallExpression(ResolveVisitor.java:903) at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:662) at org.codehaus.groovy.control.ResolveVisitor.transformDeclarationExpression(ResolveVisitor.java:931) at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:654) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:148) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:38) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:129) at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1049) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:52) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:73) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:80) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:53) at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:166) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:88) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1004) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:48) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1028) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141) at
    etc...


    I am sure i doing something wrong.


    Then after some random attempts i got the original solution posted by Dain to work:

    def testSuite = testRunner.testCase.testSuite.project.testSuites['testSuite_I_want']
    def properties = new com.eviware.soapui.support.types.StringToObjectMap()
    log.info(testSuite.getTestCaseAt(1))
    def t=testSuite.getTestCaseAt(1)
    t.run(properties,false)

    this made it work for me.


    few question:


    1. How am i using Nenad suggestion wrong and how to correct it?
    2. The properties variable, does it pass any poperties from test suite 1 to the desired test suite I want? or do i have to use pass it on using context.myvaribale'?

    Thanks
    star
  • Hello,

    To pass properties from testSuite to another TestSuite :


    for( prop in ts2.properties ) {
      log.info prop.key
      log.info prop.value.value

      ts.setPropertyValue( prop.key, prop.value.value)
      }



    where ts and ts2 are test suites. try this for test cases it should work, too.
    btw. log.info should be removed, it is there just to be sure.

    You could get testCase from test suite by:


    def testCase = ts.testCases["<testCase name>"]



    Does this helps? Let me know,

    robert