Forum Discussion

hutabarat2014's avatar
hutabarat2014
Contributor
10 years ago

Transfer a Property at Test Suite Level to All Test Cases

Hi All,

In a different post, I got the following code for transferring a property at Project level to ALL TEST CASES:

for (projectProperty in project.getPropertyList()){
if (projectProperty.getName().contains("c_")){
for (testSuite in project.getTestSuiteList()){
for (testCase in testSuite.getTestCaseList()){
testCase.setPropertyValue(projectProperty.getName(), projectProperty.getValue())
}
}
}
}


The question is that I got a property at one Test Suite that I would like to transfer to ALL TEST CASES.

What would be the right groovy script for this issue?

Many thanks,
Leo

3 Replies

  • Can I just clarify my post above?

    Essentially, I would like to find out how to access a project property from inside a Test Case (a groovy script).

    Thanks.
  • This is what I could come up with:

    def ABC = testRunner.testCase.testSuite.project.getTestSuiteList()
    def DEF = testRunner.testCase.testSuite.getPropertyValue("w2_SessionID")

    for (testSuite in ABC){
    for (testCase in testSuite.getTestCaseList()){
    testCase.setPropertyValue("w2_SessionID", DEF)
    }
    }