Forum Discussion

hutabarat2014's avatar
hutabarat2014
Contributor
10 years ago

How to clean properties at Test Case and Test Suite Levels?

Hi All,

I have been messing around with properties at Test Case and Test Suite Levels.

On exit, in TearDown Script at Project Level, I would like to have all these properties at Test Case and Test Suite Levels to be wiped out, leaving clean slate.

How do I do that?

Many thanks,
Leo

5 Replies

  • Cizo89's avatar
    Cizo89
    Frequent Contributor
    Hi Leo,

    try this script for your Project Teardown script:

    for (testSuite in project.getTestSuiteList()){
    for (i in 1..testSuite.getPropertyCount()){
    testSuite.removeProperty(testSuite.getPropertyAt(0).getName())
    }

    for (testCase in testSuite.getTestCaseList()){
    for (i in 1..testCase.getPropertyCount()){
    testCase.removeProperty(testCase.getPropertyAt(0).getName())
    }
    }
    }


    If you want just to remove all values from those properties, just use method setPropertyValue(String, String) and set the values to empty string or null (depending on your requirements).

    Regards,
    Marek
  • Liberty_Informa's avatar
    Liberty_Informa
    Regular Contributor
    Hi Leo

    Try following script which works awesome. It helps me bringing back soapUI projects to the original state. Before this script developers complained that soapUI showing us files to check-in which we haven't changed. It happens because when you run soapUI project settings.xml and testcases file are updated with the current test data and they are shown as pending changes to check-in into the version control tool. The script helps me avoiding that situation.

    It doesn't wipe out properties altogether. It just wipes out values.

    for( t in project.testSuiteList )
    {
    for( c in t.testCaseList )
    {
    clearProperties( c )
    clearProperties( t )
    }
    }

    void clearProperties( modelItem )
    {
    for( n in modelItem.propertyNames )
    modelItem.setPropertyValue( n, '' )
    }


    soapUI guys provided me this script so big thanks should go to them.
  • Cizo89's avatar
    Cizo89
    Frequent Contributor
    Hi Leo,

    that failed because one of your TestSuites or TestCases have no properties.
    Just add if statements with following conditions and it should work:
    testSuite.getPropertyCount() > 0
    testCase.getPropertyCount() > 0

    Regards,
    Marek