ChanGan
ChanGan

Reputation: 4318

Can we get test execution for each test case using closure in soapui

I have around 400 test cases in soapui.. it does not have starttime and end time or total execution of test case is not added in the custom report. I can get this by adding a script in tear down script in each test case. But it is little time taken work since I have 400 test case. Is there any way we can get by using closure in groovy..

Thanks

Upvotes: 0

Views: 289

Answers (1)

Lerminou
Lerminou

Reputation: 199

That's an example to setup the teardown in a whole project

    def project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("MyProject");

    //TearDownTemplate
    def tearDownTemplate = """
        /*BEGINNING CUSTOM TEARDOWN FOR THIS TESTCASE ONLY*/
            //Reserved for this testcase only, because the teardown is populated automaticly, we don't want to loose some work if we need specials things.

        /*END OF CUSTOM TEARDOWN HERE £££*/

        // Common teardown for all testcases Here
        // Here do the stuff for your time execution
    """;

    //Loop through each Test Suite in the project
    for(suite in project.getTestSuiteList()) {
            //Loop through each Test Case
            for(tcase in suite.getTestCaseList()) {
                teardown = tcase.getTearDownScript();
              if(teardown != null){
                // we split the teardownTemplate and the teardown already set by our delimiter '£££' 
                    def fields = teardown.tokenize("£££");
                    def fieldsTemplate = tearDownTemplate.tokenize("£££");
                    //teardown replacement
                   tcase.setTearDownScript(fields[0] + "£££" + fieldsTemplate[1]);
                }else{
                     tcase.setTearDownScript(tearDownTemplate);
                }
            }

    }
    log.info 'finished'

Upvotes: 1

Related Questions