2016-08-30 1 views
1

У меня есть некоторые пользовательские свойства для всех тестовых примеров в SoapUI.Как удалить свойства custome из тестового примера SOAPUI с помощью java?

Я могу удалить с помощью 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

Поскольку вы должны применять removeProperty в WsdlTestCase не в WsdlTestRunContext. Вы можете изменить свой TestCase кода цикла что-то вроде:

for(TestCase testCase : allTestCaseList) { 
    List<TestProperty> testCasePropertyList = testCase.getPropertyList(); 
     for (TestProperty testProperty : testCasePropertyList) { 
      ((WsdlTestCase) testCase).removeProperty(testProperty.getName()); 
     } 
} 

Надеется, что это помогает,

+0

Это работает отлично. Спасибо за ответ :) – HemaSundar

+0

@HemaSundar приятно вам помочь ':)' – albciff

Смежные вопросы