2016-08-30 59 views
1

我對SoapUI中的所有測試用例都有一些自定義屬性。如何使用java從SOAPUI測試用例中刪除custome屬性?

我能夠使用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。你可以改變你測試用例循環代碼類似:

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

希望它能幫助,

+0

這是工作的罰款。謝謝你的回覆:) – HemaSundar

+0

@HemaSundar很高興幫助你':)' – albciff

相關問題