我们可以使用soapui中的闭包来为每个测试用例执行测试执行

时间:2017-09-05 03:38:13

标签: groovy soapui

我在soapui中有大约400个测试用例..它没有开始时间和结束时间,或者自定义报告中没有添加测试用例的总执行。我可以通过在每个测试用例中的拆卸脚本中添加脚本来实现此目的。但是因为我有400个测试用例,所以很少花时间工作。我们有什么方法可以通过在groovy中使用闭包来实现..

由于

1 个答案:

答案 0 :(得分:1)

这是在整个项目中设置拆解的一个例子

    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'