Forum Discussion

MHolmqvist's avatar
MHolmqvist
Occasional Contributor
11 years ago

[Res] Random order of test cases

Hey,

Would it be possible to run test cases within a test suite in random order?
Or even across all test suites if all test suites are started?
Variation of execution order is good.

/magnus

3 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    May be you can try doing using a groovy script.
  • Trying putting this script in your TestSuite's "Setup Script".
    (It requires that all of the TestCases be disabled, but its just a proof-of-concept)


    // Get list of test cases
    myTestCases = testSuite.getTestCaseList();

    // Shuffle the list
    long seed = System.nanoTime();
    Collections.shuffle(myTestCases, new Random(seed));

    boolean aFailureOccured = false;

    // Run each test case
    for(testCase in myTestCases){
    def properties = new com.eviware.soapui.support.types.StringToObjectMap ()
    def async = false
    result = testCase.run(properties, async).getStatus().toString();
    if (result == "FAILED"){
    aFailureOccured = true;
    }
    }

    // Set the TestSuite's result
    if (aFailureOccured){
    runner.setStatus(com.eviware.soapui.model.testsuite.TestRunner.Status.FAILED)
    } else {
    runner.setStatus(com.eviware.soapui.model.testsuite.TestRunner.Status.FINISHED)
    }