Forum Discussion

Kees's avatar
Kees
Occasional Contributor
8 years ago

How can I autoreplay one of my testcases?

Hello,

 

I would like to autoreplay one of my testcases. Is that possible within SoapUI NG pro? And so yes, on what manner?

 

Kind regards,

 

Kees

  • You can use test case Teardown scripts to do this. This script should work, but there are probably lots of simpler ways.

     

     

    // IMPORTANT. CAN CAUSE INFINITE LOOP WITHOUT ITERATOR
    for (i = 0; i <1; i++) { def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("TestSuite 1").getTestCaseByName("TestCase 1") def properties = new com.eviware.soapui.support.types.StringToObjectMap () def async = false testCase.run (properties, async) }

     

  • nmrao's avatar
    nmrao
    Champion Level 3
    If the test case is created earlier, then the same can be run any number of times.
  • You can use test case Teardown scripts to do this. This script should work, but there are probably lots of simpler ways.

     

     

    // IMPORTANT. CAN CAUSE INFINITE LOOP WITHOUT ITERATOR
    for (i = 0; i <1; i++) { def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("TestSuite 1").getTestCaseByName("TestCase 1") def properties = new com.eviware.soapui.support.types.StringToObjectMap () def async = false testCase.run (properties, async) }

     

    • Kees's avatar
      Kees
      Occasional Contributor

      Igor, thank you very much!


      That script works! But another question. How can I stop that script during the loop? Or is there an option that I can replay the script for 10 or another number times?

      • IgorG's avatar
        IgorG
        Staff

        You can use this notation to exit the loop at any time:

        if(condition) {
            break;
        }

        Or you can change the i=x value in the loop to run a specific number of times.

  • rajpenumalli's avatar
    rajpenumalli
    Occasional Contributor
    Hi knees ,
    Just by giving break you can stop looping but it is better to know you stopped looping becoz you reached the condition.
    Also asynchronous is Boolean value and this will decide test case to run in parallel or sequential mode.

    Here is the corrected code snippet:
    boolean async=true:// true to run parallel and false to run sequential
    for (i = 0; i < 3; i++)
    {
    def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Medewerkers").getTestCaseByName("Niet-gekeurde medewerkers verwijderen")
    def properties = new com.eviware.soapui.support.types.StringToObjectMap ()
    def async = false
    testCase.run (properties, async)
    if (i == 2) {
    test runner.cancel("i value reached to 2" )
    break;}
    }

    Hip it helps

    _Rajendra Prasad Reddy Penumalli
      • Kees's avatar
        Kees
        Occasional Contributor

        Thank's all. I have now already an solution with a data source loop.