0

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

ChanGan
  • 4,254
  • 11
  • 74
  • 135
  • Do you already have `Teardown Script`? It would be good if you can add it in the question? And how exactly you want it In the report? Sample report would help. What kind report are you looking for? html? a plain text? – Rao Sep 05 '17 at 05:30
  • Here is another question with report generation which was answered some time ago. May not be relevant, but have a look at it. https://stackoverflow.com/questions/41700437/creating-a-test-report-from-project-level-tear-down-script – Rao Sep 05 '17 at 05:34
  • @Rao, I don have Teardown script.. I want Total Execution Time take for Each suite..Like Card Management Start Time: xxx and End Time: xxxx or Total time take: xxx – ChanGan Sep 05 '17 at 06:11
  • But, the question says test case wise? Any ways, how many suites you got? – Rao Sep 05 '17 at 06:21
  • You can also use a script to populate all the teardowns in all your testcases with a template. I use this method to populate more than 1500 testcases and it runs in less than 2 seconds. – Lerminou Sep 05 '17 at 08:06
  • @ChanGan, how do you execute the tests? The time taken for execution is shown if testrunner is used. See the screen shot - https://www.soapui.org/test-automation/running-functional-tests.html – Rao Sep 05 '17 at 08:07
  • @ChanGan, if you look at junit style report, it has time for each test case already - https://www.soapui.org/reporting/generating-html-reports.html. I would say, the question does not clearly say what exact is needed. – Rao Sep 05 '17 at 08:16
  • @Lerminou/@Rao, Can we add in all Test case Tear Down script to get the time take using one script?? – ChanGan Sep 05 '17 at 08:18
  • @ChanGan, there are unanswered questions in the earlier comments. Please go thru the previous comments, and update the question accordingly with clear expectations to resolve the problem. – Rao Sep 05 '17 at 08:20
  • @ChanGan, see if [this extension](https://github.com/nmrao/soapuiExtensions) is useful to you, which can run some arbitrary code on meeting certain condition in SoapUI Open Source edition; just similar to [Events feature](https://support.smartbear.com/readyapi/docs/testing/handling-events.html) of ReadyAPI. This way, you do not have to repeat the code; less code, less maintenance. – Rao Sep 05 '17 at 09:08
  • Thanks Lerminou and Rao.. the below answers works out for me.. @Rao, I dont have Ready API. – ChanGan Sep 05 '17 at 10:16
  • Not sure you got the comments right.not marked below one as answered then. – Rao Sep 05 '17 at 10:25
  • Yes. I accepted now.. – ChanGan Sep 05 '17 at 11:41

1 Answers1

1

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'
Lerminou
  • 189
  • 1
  • 9