我对SoapUI中的所有测试用例都有一些自定义属性。
我可以使用Groovy脚本步骤删除,如以下问题所述:
如何使用Groovy从SoapUI TestCase中删除自定义属性?
testRunner.testCase.removeProperty( "Testcase_Property" );
但是我想从JAVA中删除这些属性。以下是我编写的代码:
String soapuiProjectPath = "ProjectLocation";
WsdlProject project = new WsdlProject(soapuiProjectPath);
StringToObjectMap context = new StringToObjectMap();
TestSuite testSuite = project.getTestSuiteByName("TestSuiteName");
WsdlTestSuite wsdlSuite = (WsdlTestSuite) testSuite;
List<TestCase> allTestCaseList = wsdlSuite.getTestCaseList();
for (TestCase testCase : allTestCaseList) {
WsdlTestCaseRunner testCaseRunner = new WsdlTestCaseRunner((WsdlTestCase) testCase, context);
List<TestProperty> testCasePropertyList = testCase.getPropertyList();
for (TestProperty testProperty : testCasePropertyList) {
WsdlTestRunContext runContext = testCaseRunner.getRunContext();
runContext.removeProperty(testProperty.getName());
}
}
System.out.println("Completed execution.");
project.save();
它不会引发任何异常。但实际上也没有删除自定义属性。
因为您必须将removeProperty
in应用于WsdlTestCase
not in中WsdlTestRunContext
。您可以将testCase循环代码更改为以下内容:
for(TestCase testCase : allTestCaseList) {
List<TestProperty> testCasePropertyList = testCase.getPropertyList();
for (TestProperty testProperty : testCasePropertyList) {
((WsdlTestCase) testCase).removeProperty(testProperty.getName());
}
}
希望能帮助到你,
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句