Forum Discussion

JustinM89's avatar
JustinM89
Contributor
8 years ago

Clear REST request on saving?

I discovered today that the settings.xml file for our SoapUI composite project is a whopping 500,000 lines and nearly 50MB. The reason for this is because of the way we structure our test cases. We u...
  • JustinM89's avatar
    JustinM89
    8 years ago

    OK, I've found a suitable solution using existing event handlers. I added a TestRunListener.afterRun handler with the following code:

     

    testCase = context.getTestCase()

    for (tStep in testCase.getTestStepList()) { String request = tStep.getPropertyValue("request") if (request.length() > 500) { tStep.setPropertyValue("request", "") } }

    This will execute after any test is executed, even if the test is canceled or fails.

     

    While I was at it, I also added handlers for clearing custom properties as well. This should hopefully help with managing the project in SVN -- we have a ton of properties that are generated each test run and these files show as conflicted every single time we sync. We really only need the properties at run time, so I added handlers to clear those too. The code is below for anyone interested:

     

    TestRunListener.afterRun to clear test case level properties

    testCase = context.getTestCase()
    
    testCase.properties.each {
    	testCase.properties[it.key].value = ''
    }

    TestSuiteRunListener.afterRun to clear test suite level properties

    testRunner.testSuite.properties.each {
    	testRunner.testSuite.properties[it.key].value = ''
    }