1

I have some custom properties for all the test cases in SoapUI.

I am able to delete using Groovy script step as described in below question:

How to remove Custom Properties from a SoapUI TestCase using Groovy?

testRunner.testCase.removeProperty( "Testcase_Property" );

But I wanted to delete these properties from JAVA. Below is the code I wrote:

    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();

It is not throwing any exception. But not actually removing the custom properties as well.

Community
  • 1
  • 1
HemaSundar
  • 1,263
  • 3
  • 17
  • 28

1 Answers1

0

Because you've to apply the removeProperty in WsdlTestCase not in WsdlTestRunContext. You can change your testCase loop code for something like:

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

Hope it helps,

albciff
  • 18,112
  • 4
  • 64
  • 89