Forum Discussion

divman's avatar
divman
Contributor
11 years ago

How to schedule the regression scripts.

Hi,

I am new to soapui pro and i am using SoapUI Pro 4.6.4. All my developed regression scripts, based on my requirement, will look like below.

Project 1
--TestSuite1
----TestCase1 (i open here and click on the run button to run this regression suite with excel as data source with groovy script)

once my project 1 --> test suite finishes, i open the second project and navigating to test case...

Project 2
--TestSuite2
----TestCase2 (again i open here and click on the run button to run this regression suite with excel as data source with groovy script)

Whenever my release comes i use to run my regression suites as specified. This requires manual interaction. So, I am looking for a solution to make all my scripts run by having kind of a batch file (or any other solution) at one click. So if i want to run all my suite, i can have any batch or any kind of scheduler in a remote machine, just run or call that file and all my regression suite should run one after another and finally looking for the results in a PDF report and also no manual interaction will be required.

Is this possible? if so, Could anyone help me on this?

9 Replies

  • Thanks for your time. i tried with the Test Runner as specified in the soapui web page. I tried for one test case through test runner (with Launch TestRunner option), and i am getting an error. But the same test case is running successfully without any error when i run through soapui tool (just opening the test case and click on the Green run button). below is the error i am getting thro Launch TestRunner option. Could you please help me on this?.

    Running SoapUI TestRunner for [Holds Inquiry - Groovy Automation]
    directory: C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin
    command: cmd.exe /C testrunner.bat -sAcctHoldInq -cHolds_Inquiry_Testcase -r -f"C:\Capital One\Xpress\Groovy Automation\TestRunner Reports" -R"TestSuite Report" -EDefault "C:\Capital One\Xpress\Groovy Automation\Holds Inquiry\Holds-Inquiry---Groovy-Automation-soapui-project.xml"
    SoapUI Pro 4.6.4 TestCase Runner
    Configuring log4j from [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\soapui-log4j.xml]
    09:47:34,756 INFO [SoapUI] Adding [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\ext\postgresql-8.3-604.jdbc3.jar] to extensions classpath
    09:47:34,757 INFO [SoapUI] Adding [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\ext\postgresql-8.3-604.jdbc4.jar] to extensions classpath
    09:47:34,758 INFO [SoapUI] Adding [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\ext\SAFE_Plus.jar] to extensions classpath
    09:47:34,758 INFO [SoapUI] Adding [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\ext\SAFE_PLUS_old.jar] to extensions classpath
    09:47:34,759 INFO [SoapUI] Adding [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\ext\sqljdbc.jar] to extensions classpath
    09:47:35,147 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\Users\PAR964\soapui-settings.xml]
    09:47:35,449 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library to [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\scripts]
    09:47:35,451 INFO [DefaultSoapUICore] Adding listeners from [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\listeners\demo-listeners.xml]
    09:47:35,458 INFO [DefaultSoapUICore] Adding plugin from [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\plugins\soapui-groovy-console-plugin-1.0-plugin.jar]
    09:47:36,481 INFO [WsdlProject] Loaded project from [file:/C:/Capital%20One/Xpress/Groovy%20Automation/Holds%20Inquiry/Holds-Inquiry---Groovy-Automation-soapui-project.xml]
    09:47:36,602 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library to [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\scripts]
    09:47:37,073 INFO [SoapUIProTestCaseRunner] Running SoapUI tests in project [Holds Inquiry - Groovy Automation]
    09:47:37,102 INFO [SoapUIProTestCaseRunner] Running TestCase [Holds_Inquiry_Testcase]
    09:47:38,157 ERROR [AbstractTestRunner] Exception during Test Execution
    java.lang.NullPointerException: Cannot invoke method getProjectByName() on null object
    at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    ....
    ....
    ....
    09:47:38,196 ERROR [SoapUI] An error occurred [null\null (The system cannot find the path specified)], see error log for details
    09:47:38,197 INFO [SoapUIProTestCaseRunner] Finished running SoapUI testcase [Holds_Inquiry_Testcase], time taken: 0ms, status: FAILED
    09:47:38,198 ERROR [SoapUI] An error occurred [java.lang.NullPointerException], see error log for details
    09:47:38,199 INFO [SoapUIProTestCaseRunner] TestCase [Holds_Inquiry_Testcase] finished with status [FAILED] in 0ms
    java.io.FileNotFoundException: null\null (The system cannot find the path specified)
    at java.io.FileOutputStream.open(Native Method)...
    ...
    ...
    ...

    SoapUI 4.6.4 TestCaseRunner Summary
    -----------------------------
    Time Taken: 1163ms
    Total TestSuites: 0
    Total TestCases: 1 (1 failed)
    Total TestSteps: 0
    Total Request Assertions: 0
    Total Failed Assertions: 0
    Total Exported Results: 0
    09:47:38,237 ERROR [SoapUIProTestCaseRunner] java.lang.Exception: TestCase [Holds_Inquiry_Testcase] failed without assertions

    09:47:38,237 ERROR [SoapUI] An error occurred [TestCase [Holds_Inquiry_Testcase] failed without assertions
    ], see error log for details
    java.lang.Exception: TestCase [Holds_Inquiry_Testcase] failed without assertions

    at com.eviware.soapui.tools.SoapUITestCaseRunner.throwFailureException(SoapUITestCaseRunner.java:531)
    at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:433)
    at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:158)
    at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:89)
    at com.eviware.soapui.SoapUIProTestCaseRunner.main(SourceFile:58)
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Looks like you are using an instance of Workspace in the groovy script and that is null while running from command line, probably because there is no workpsace object available for command line test runner.
    Can you please fix the groovy script or share it?

    Best Regards,
    Prakash
    SmartBear Sweden
  • Here is my groovy. I have Workspace which has two projects "Holds Inquiry" and "Library". I am having all my reusable common codes in my Library project. When i run my "Holds Inquiry", in the Setup Script, i have a below code which i will get the testdata from excel as datasource (though Pro version has datasource option, i need to do more other stuff, so i am using Groovy) and do my other stuff.

    import org.apache.poi.hssf.usermodel.*;
    dFormatter = new HSSFDataFormatter()
    groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def projectPath = groovyUtils.projectPath
    def fileName = "Holds_Inquiry__TestData.xls"
    srcBook = new HSSFWorkbook(new FileInputStream(new File(projectPath + "\\" + fileName)))
    fEval = new HSSFFormulaEvaluator(srcBook)
    sourceSheet = srcBook.getSheetAt(0)
    context.rowCounter = 1
    library = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("Library")
    suitename = library.getTestSuiteByName("Driver_Scripts");
    module1 = suitename.testCases["Methods"].testSteps["Initialize_DataSetup"]
    module1.run(testRunner, context)
    def dataverifySheet
    def startTestData = context.InitializeTestData
    startTestData.FirstData(sourceSheet, dataverifySheet, dFormatter, fEval, projectPath)
    context.srcWkSheet = sourceSheet
    context.projPath = projectPath

    my above code will be calling an another Project named "Library", which is having a test case "Methods", which has a step "Initialize_DataSetup", which has a reusable code (here to get the testdata from sxcel as source..). This is my setup.

    I am getting error when i run through TestRunner. Could you please help me on this? Because we have all our regression suites with this structure (developed before converting to SoapUI Pro).
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    It looks like this line is causing the error because running through the command line the workspace is null i.e doesn't exist in that context.


    library = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("Library")


    To get the project try this:


    import com.eviware.soapui.impl.wsdl.WsdlProject
    //path to project file as argument
    def library = new WsdlProject("C:\\SoapUI\\SOAPUI Projects\\JMS-Demo-Test-soapui-project.xml")


    Then you will be able to use the project methods such as getTestSuiteByName.


    Regards,
    Marcus
    SmartBear Support
  • Thank You Marcus.
    your code helped me to resolve that issue. But i am facing another exception. The error now is...
    ...
    ...
    ...
    12:06:04,313 INFO [DefaultSoapUICore] Adding listeners from [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\listeners\demo-listeners.xml]
    12:06:04,320 INFO [DefaultSoapUICore] Adding plugin from [C:\Program Files (x86)\SmartBear\SoapUI-Pro-4.6.4\bin\plugins\soapui-groovy-console-plugin-1.0-plugin.jar]
    12:06:05,219 INFO [WsdlProject] Loaded project from [file:/C:/Capital%20One/Xpress/Groovy%20Automation/Holds%20Inquiry/Holds-Inquiry---Groovy-Automation-soapui-project.xml]
    12:06:05,304 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library to [C:\Manimaran\GroovyClasses]
    12:06:05,614 INFO [SoapUIProTestCaseRunner] Running SoapUI tests in project [Holds Inquiry - Groovy Automation]
    12:06:05,637 INFO [SoapUIProTestCaseRunner] Running TestCase [Holds_Inquiry_Testcase]
    12:06:06,371 INFO [WsdlProject] Loaded project from [file:/C:/Capital%20One/Xpress/Groovy%20Automation/Library%20and%20Methods/Library-soapui-project.xml]
    12:06:06,694 ERROR [AbstractTestRunner] Exception during Test Execution
    java.lang.NullPointerException: Cannot invoke method getLogArea() on null object
    at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at InitializeTestData.FirstData(Script1.groovy:31)
    ...
    ...
    ...

    To be clear...as i said in my previous post, the code which i has in Setup Script which calls the the library code in the library project, which my "InitializeTestData" code is below..could you please help me to resolve what is the problem here...?

    class InitializeTestData
    {
    log.info("inside InitializeTestData class........")
    def log
    def context
    def testRunner
    def InitializeTestData(logIn,contextIn,testRunnerIn)
    {
    this.log = logIn
    this.context = contextIn
    this.testRunner = testRunnerIn
    }
    def FirstData(sourceSheet, dataverifySheet, dFormatter, fEval, projectPath)
    {
    def headerRow, sourceRow, headerRow_value, sourceRow_cell
    def dataheaderRow, datasourceRow, dataheaderRow_value, datasourceRow_cell
    def ran_num, random, randomInteger
    def datetime, ReportPath, folder, soapuilogclear
    int m, n, i

    //clear all the logs before start of test suite everytime
    log.info ("1....")
    try
    {
    log.info ("2....")
    com.eviware.soapui.SoapUI.logMonitor.getLogArea("soapUI log").clear()
    } catch(Exception ex)
    {
    log.info ("3....")
    com.eviware.soapui.SoapUI.logMonitor.getLogArea("SoapUI log").clear()
    }
    log.info ("4....")
    com.eviware.soapui.SoapUI.logMonitor.getLogArea("script log").clear()
    log.info ("5....")
    com.eviware.soapui.SoapUI.logMonitor.getLogArea("http log").clear()
    log.info ("6....")
    com.eviware.soapui.SoapUI.logMonitor.getLogArea("error log").clear()
    log.info ("7....")
    //Read in the contents of the first row. Set to 1 if we have headers
    headerRow = sourceSheet.getRow(0)
    sourceRow = sourceSheet.getRow(1)
    for(m=0; m<headerRow.getLastCellNum(); m++)
    {
    headerRow_value = headerRow.getCell(m)
    sourceRow_cell = sourceRow.getCell(m)
    testRunner.testCase.setPropertyValue(headerRow_value.toString(),dFormatter.formatCellValue(sourceRow_cell,fEval))
    }
    }
    }

    context.setProperty( "InitializeTestData", new InitializeTestData( log, context, testRunner) )


    Much appreciate your help.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

     com.eviware.soapui.SoapUI.logMonitor.getLogArea("soapUI log").clear()


    is to clear the console logs in the GUI. You should remove (and possibly backup) the .log files in the <SoapUI Pro install>\bin directory before you run your tests with testrunner (use batch file or seperate script to do this) if you want a clean log file for each run.




    Regards,
    Marcus
    SmartBear Support
  • Thanks Marcus.

    With your help now i am able to run my test thro' TestRunner batch without any issues.

    I need a suggestion. As you said, the logs will be cleared only in the GUI level test run, is it possible to use the logic during my TestRunner execution also?. The reason is my test suite will be running for more number of inputs and i use many "Log.info ("")" query in many areas of my script. So during my execution, for all the inputs it will go for sequence of validation and i use to print the values of every variables and in steps that will put in script log. Finally from the TearDown Script step, i write a code to get all the log contents for every test case (i mean every test data running) and put it in a .txt file. So that i can find out what is happening in the execution time and what are all the datas are flowing in and out. This will also be used as a debugger for my suite.

    Is there any possible? Please let me know. Thanks Much again.