Groovy 如果其中一个http API http状态代码不是200,如何停止testRunner

Groovy 如果其中一个http API http状态代码不是200,如何停止testRunner,groovy,soapui,Groovy,Soapui,我正在一台CI机器上运行我的soapUI自动化解决方案,由testRunner.sh调用 按如下方式调用: /Projects/SoapUI-5.2.1/bin/testrunner.sh ~/sautomation_work/Automation_Project.xml public testSuiteStop() { def properties = new com.eviware.soapui.support.types.StringToObjectMap(); def

我正在一台CI机器上运行我的soapUI自动化解决方案,由testRunner.sh调用

按如下方式调用:

/Projects/SoapUI-5.2.1/bin/testrunner.sh ~/sautomation_work/Automation_Project.xml
public testSuiteStop() {
    def properties = new com.eviware.soapui.support.types.StringToObjectMap();
    def reportTestCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Report").getTestCaseByName("FinalReport");
    reportTestCase.run(properties, true);
    def testSuite = context.testCase.testSuite;
    def totalTestCases = testSuite.getTestCases().size();
    for(testCaseItem in (0..totalTestCases-1)) {    
        testSuite.getTestCaseAt(testCaseItem).setDisabled(true)
    }
}
如果某个API http状态代码不是200,我想停止整个过程

有什么想法吗? 目前,我能做到这一点的唯一方法是调用最后一个测试套件“FinalReport”,并禁用运行中测试套件中当前可用的其余测试脚本

代码如下:

/Projects/SoapUI-5.2.1/bin/testrunner.sh ~/sautomation_work/Automation_Project.xml
public testSuiteStop() {
    def properties = new com.eviware.soapui.support.types.StringToObjectMap();
    def reportTestCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Report").getTestCaseByName("FinalReport");
    reportTestCase.run(properties, true);
    def testSuite = context.testCase.testSuite;
    def totalTestCases = testSuite.getTestCases().size();
    for(testCaseItem in (0..totalTestCases-1)) {    
        testSuite.getTestCaseAt(testCaseItem).setDisabled(true)
    }
}

我找到了一种方法,可以在一个关键测试失败的情况下退出当前的soapUI执行。 其思想是禁用剩余的测试套件和测试用例,并执行一个“最终”测试套件,该套件报告失败的测试执行

我的代码如下所示:

import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlTestSuite;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;

WsdlTestSuite testSuite = context.testCase.testSuite;
WsdlProject project     = context.testCase.getProject();

// Disable remaining test cases in the current test suite.
for (WsdlTestCase testCase in testSuite.testCaseList) {
    testCase.setDisabled(true);
}

// Disable rest of the test suites
for (WsdlTestSuite testSuiteName in project.testSuiteList) {
    testSuiteName.setDisabled(testSuiteName.name != "LastTestSuite");
}

如果您有SoapUI Pro,则可以创建自定义事件。在免费版本中,您的解决方案与您将获得的一样好。感谢您的建议,我将进一步研究解决方案。