我为 SoapUI 中的所有测试用例提供了一些自定义属性。
我可以使用 Groovy 脚本步骤进行删除,如下问题所述:
How to remove Custom Properties from a SoapUI TestCase using Groovy?
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();
它没有抛出任何异常。但实际上并没有删除自定义属性。
最佳答案
因为您必须在 WsdlTestCase
中应用 removeProperty
,而不是在 WsdlTestRunContext
中。您可以将 testCase 循环代码更改为:
for(TestCase testCase : allTestCaseList) {
List<TestProperty> testCasePropertyList = testCase.getPropertyList();
for (TestProperty testProperty : testCasePropertyList) {
((WsdlTestCase) testCase).removeProperty(testProperty.getName());
}
}
希望对你有帮助
关于java - 如何使用 java 从 SOAPUI 测试用例中删除自定义属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39220938/