Forum Discussion

stephensurya's avatar
stephensurya
New Contributor
15 years ago

[RESOLVED]how to run testsuites in multiple projects in one click from the UI?

Hi,
I have a few projects with test suites, test cases, etc.

At present I open the projects in SoapUI, double click the project, go to the "TestSuites" tab and run the test cases in parallel. I repeat the steps for all my projects to run the testsuites/testcases in the project.

I also have a Junit testsuite in my java layer that uses SoapUITestCaseRunner to run all my SoapUI projects/testsuites/testcases. Now, is it possible to do the same thing using a Groovy script inside SoapUI?

Basically I'm looking for a Groovy script code that can load another project(s) and run its testsuites/testcases and at the same time provide me the visual aspect of it. This way all I'd have to do would be to open the one project that has my groovy script and run it which will run all the other ones.

I guess the easiest thing to do would be to put all the TestSuites in just one project, but we have a lot of testsuites to write and our XML is going to get very bulky - so we'd like to keep the current structure as it is but still be able to run the other project testsuites.

Please help!

thanks,
Stephen

9 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    Create a new Project with a TestCase and a single Groovy TestStep:


    for(project in com.eviware.soapui.SoapUI.workspace.projectList) {
    if(project.open && project.name != testRunner.testCase.testSuite.project.name) {
    log.info "Running project: " + project.name
    project.run( null, false )
    }
    }


    Running this will cause all other open Projects to run, good luck!

    Regards,
    Dain
    eviware.com
    • Jazz's avatar
      Jazz
      Occasional Contributor

      Hello,

       

      this look like what i need, but when i run this groovy script, i get following error

       

      java.lang.NullPointerException
      error at line: 4

       

      when i run whole project (with only this script) i get this from error log

       

      Wed Jan 20 14:29:30 CET 2016:ERROR:java.lang.NullPointerException
         java.lang.NullPointerException
         	at com.eviware.soapui.impl.wsdl.WsdlProjectPro.a(WsdlProjectPro.java:1041)
         	at com.eviware.soapui.impl.wsdl.WsdlProjectPro.run(WsdlProjectPro.java:1033)
         	at com.eviware.soapui.impl.wsdl.WsdlProjectPro.run(WsdlProjectPro.java:1)
         	at com.eviware.soapui.model.testsuite.TestRunnable$run.call(Unknown Source)
         	at Script15.run(Script15.groovy:4)
         	at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
         	at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:76)
         	at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:155)
         	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:234)
         	at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47)
         	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:148)
         	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:1)
         	at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:130)
         	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
         	at java.util.concurrent.FutureTask.run(Unknown Source)
         	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
         	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         	at java.lang.Thread.run(Unknown Source)

      Looks like function project.run( null, false ) have problems with null (not sure, just my opinion) but i cant find any doc for this function, so i dont know what "null" and "false" means.

       

      Any idea whats wrong here, or where to find doc about that function?

       

      Thnx

       

  • nbathija's avatar
    nbathija
    Occasional Contributor
    Did anyone try the above scripts. I tried when I executed the above script throuh UI no results /error was return and on command line below error was thrown. Though workspace and projects xmls are located in the same directory



    C:\Users\noopur.bathija>testrunner.bat C:\Users\noopur.bathija\Desktop\Test-soap
    ui-project.xml
    soapUI Pro 3.6.1 TestCase Runner
    13:58:32,854 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\User
    s\noopur.bathija\soapui-settings.xml]
    13:58:33,477 INFO [DefaultSoapUICore] Adding listeners from [C:\Program Files\e
    viware\soapUI-Pro-3.6.1\bin\listeners\demo-listeners.xml]
    13:58:33,731 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library t
    o [C:\PROGRA~1\eviware\SOAPUI~1.1\bin\scripts]
    13:58:33,872 INFO [WsdlProject] Loaded project from [file:C:/Users/noopur.bathi
    ja/Desktop/Test-soapui-project.xml]
    13:58:33,912 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library t
    o [C:\PROGRA~1\eviware\SOAPUI~1.1\bin\scripts]
    13:58:34,224 INFO [SoapUIProTestCaseRunner] Running soapUI tests in project [Te
    st]
    13:58:34,227 INFO [SoapUIProTestCaseRunner] Running Project [Test], runType = S
    EQUENTIAL
    13:58:34,240 INFO [SoapUIProTestCaseRunner] Running soapUI testcase [TestCase 1
    ]
    13:58:34,241 INFO [SoapUIProTestCaseRunner] running step [Groovy Script]
    13:58:34,704 ERROR [SoapUI] An error occured [Cannot get property 'projectList'
    on null object], see error log for details
    java.lang.NullPointerException: Cannot get property 'projectList' on null object

    at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56
    )
    at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.j
    ava:156)
    at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCal
    lSite.java:44)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty
    (AbstractCallSite.java:235)
    at Script1.run(Script1.groovy:1)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.
    run(SoapUIGroovyScriptEngine.java:96)
    at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngi
    neFactory$SoapUIProGroovyScriptEngine.run(SourceFile:88)
    at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(W
    sdlGroovyScriptTestStep.java:148)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runTestStep(
    WsdlTestCaseRunner.java:207)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.internalRun(
    WsdlTestCaseRunner.java:138)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.internalRun(
    WsdlTestCaseRunner.java:39)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractT
    estRunner.java:135)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
    )
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    13:58:34,721 ERROR [SoapUIProTestCaseRunner] Groovy Script failed, exporting to
    [C:\Users\noopur.bathija\TestSuite_1-TestCase_1-Groovy_Script-0-FAILED.txt]
    13:58:34,727 INFO [SoapUIProTestCaseRunner] Finished running soapUI testcase [T
    estCase 1], time taken: 471ms, status: FAILED
    13:58:34,728 INFO [SoapUIProTestCaseRunner] Project [Test] finished with status
    [FAILED] in 496ms
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    When running from the command-line the workspace is not loaded, only the specified project. Your script could check if SoapUI.workspace is null, and if it is it could load the workspace itself via the WorkspaceImpl( path, null ) constructor and then enumerate its projects in the same way as you have done already.

    Hope this helps!

    regards,

    /Ole
    eviware.com
  • byter1's avatar
    byter1
    Occasional Contributor
    Hi, The below script is working perfectly and projects are being run ok.
    Although, I am wondering is it possible to view the results from running the tests?

    Thanks for your help.

    eviware support wrote:
    Hello,

    Create a new Project with a TestCase and a single Groovy TestStep:


    for(project in com.eviware.soapui.SoapUI.workspace.projectList) {
    if(project.open && project.name != testRunner.testCase.testSuite.project.name) {
    log.info "Running project: " + project.name
    project.run( null, false )
    }
    }


    Running this will cause all other open Projects to run, good luck!

    Regards,
    Dain
    eviware.com
  • lsrinucog's avatar
    lsrinucog
    New Contributor
    hi Dain,

    The code which you have mentioned below is working fine when we run it from soapUI tool . But from command line , when we try to run it , It's throwing below error

    An error occured [Cannot get property 'projectList' on null object], see error log for details
    java.lang.NullPointerException: Cannot get property 'projectList' on null object
    at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56)
    at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:156)
    at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:44)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
    at Script1.run(Script1.groovy:1)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
    at com.eviware.soapui.impl.wsdl.WsdlProject.runAfterLoadScript(WsdlProject.java:1428)
    at com.eviware.soapui.impl.wsdl.WsdlProject.afterLoad(WsdlProject.java:523)
    at com.eviware.soapui.impl.wsdl.WsdlProject.loadProject(WsdlProject.java:385)
    at com.eviware.soapui.impl.wsdl.WsdlProject.<init>(WsdlProject.java:234)
    at com.eviware.soapui.impl.wsdl.WsdlProjectFactory.createNew(WsdlProjectFactory.java:41)
    at com.eviware.soapui.impl.wsdl.WsdlProjectFactory.createNew(WsdlProjectFactory.java:24)
    at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:319)
    at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:151)
    at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:86)
    at com.eviware.soapui.tools.SoapUITestCaseRunner.main(SoapUITestCaseRunner.java:115)
    17:27:34,928 INFO [SoapUITestCaseRunner] Running soapUI tests in project [All soapui projects]
    17:27:34,928 INFO [SoapUITestCaseRunner] Running TestCase [TestCase 1]
    17:27:34,959 INFO [SoapUITestCaseRunner] Running soapUI testcase [TestCase 1]
    17:27:34,959 INFO [SoapUITestCaseRunner] running step [Groovy Script]
    17:27:34,959 INFO [SoapUITestCaseRunner] Finished running soapUI testcase [TestCase 1], time taken: 0ms, status: FINISHED
    17:27:34,975 INFO [SoapUITestCaseRunner] TestCase [TestCase 1] finished with status [FINISHED] in 0ms

    Can you please help ?
  • yuwaan's avatar
    yuwaan
    New Contributor
    What if I have 10 projects in a list and after using below mentioned code
    for(project in com.eviware.soapui.SoapUI.workspace.projectList) {
    if(project.open && project.name != testRunner.testCase.testSuite.project.name) {
    log.info "Running project: " + project.name
    project.run( null, false )
    }
    }

    it will run all projects in one go however I want to stop in between .... Can I perform something like diz ??
  • Hi

    I am still getting the below error message when executing the below code from command prompt.

    [Cannot get property 'projectList'
    on null object], see error log for details
    java.lang.NullPointerException: Cannot get property 'projectList' on null object


    for(project in com.eviware.soapui.SoapUI.workspace.projectList) {
    if(project.open && project.name != testRunner.testCase.testSuite.project.name) {
    log.info "Running project: " + project.name
    // project.run( null, false )
    }
    }