如何使用java从SOAPUI测试用例中删除custome属性?
我对SoapUI中的所有测试用例都有一些自定义属性 我可以使用Groovy脚本步骤删除,如以下问题所述: 但是我想从JAVA中删除这些属性。下面是我写的代码:如何使用java从SOAPUI测试用例中删除custome属性?,java,soapui,Java,Soapui,我对SoapUI中的所有测试用例都有一些自定义属性 我可以使用Groovy脚本步骤删除,如以下问题所述: 但是我想从JAVA中删除这些属性。下面是我写的代码: String soapuiProjectPath = "ProjectLocation"; WsdlProject project = new WsdlProject(soapuiProjectPath); StringToObjectMap context = new StringToObjectMap();
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();
String soapuiProjectPath=“ProjectLocation”;
WsdlProject=新的WsdlProject(soapuiProjectPath);
StringToObjectMap上下文=新建StringToObjectMap();
TestSuite TestSuite=project.getTestSuiteByName(“TestSuiteName”);
WsdlTestSuite wsdlSuite=(WsdlTestSuite)testSuite;
List allTestCaseList=wsdlSuite.getTestCaseList();
for(TestCase TestCase:allTestCaseList){
WsdlTestCaseRunner testCaseRunner=新的WsdlTestCaseRunner((WsdlTestCase)测试用例,上下文);
List testCasePropertyList=testCase.getPropertyList();
for(TestProperty TestProperty:testCasePropertyList){
WsdlTestRunContext=testCaseRunner.getRunContext();
removeProperty(testProperty.getName());
}
}
System.out.println(“完成的执行”);
project.save();
它没有抛出任何异常。但实际上并不删除自定义属性。因为您必须在
WsdlTestCase
中应用removeProperty
,而不是在WsdlTestRunContext
中。您可以更改testCase循环代码,例如:
for(TestCase testCase : allTestCaseList) {
List<TestProperty> testCasePropertyList = testCase.getPropertyList();
for (TestProperty testProperty : testCasePropertyList) {
((WsdlTestCase) testCase).removeProperty(testProperty.getName());
}
}
for(TestCase-TestCase:allTestCaseList){
List testCasePropertyList=testCase.getPropertyList();
for(TestProperty TestProperty:testCasePropertyList){
((WsdlTestCase)testCase.removeProperty(testProperty.getName());
}
}
希望有帮助,因为您必须在
WsdlTestCase
中应用removeProperty
,而不是在WsdlTestRunContext
中应用。您可以更改testCase循环代码,例如:
for(TestCase testCase : allTestCaseList) {
List<TestProperty> testCasePropertyList = testCase.getPropertyList();
for (TestProperty testProperty : testCasePropertyList) {
((WsdlTestCase) testCase).removeProperty(testProperty.getName());
}
}
for(TestCase-TestCase:allTestCaseList){
List testCasePropertyList=testCase.getPropertyList();
for(TestProperty TestProperty:testCasePropertyList){
((WsdlTestCase)testCase.removeProperty(testProperty.getName());
}
}
希望对您有所帮助,@hemasandar很高兴帮助您
:)
@hemasandar很高兴帮助您:)