我为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();
它没有抛出任何异常。但实际上并没有删除自定义属性。
答案 0 :(得分:0)
因为您要npm install
removeProperty
而不是WsdlTestCase
。您可以更改 testCase 循环代码,例如:
WsdlTestRunContext
希望它有所帮助,