Forum Discussion

hutabarat2014's avatar
hutabarat2014
Contributor
10 years ago

[Res] Groovy Script To Get Project Property to Particular TC

Hi,

Basic stuff.

What is the Groovy Script to set a particular test case property from the Project Property?

Say, the Test Case is called "ABCDE".

Also, say, the Test Suite is called "XYZ".

Many thanks.
Leo

14 Replies

  • Cizo89's avatar
    Cizo89
    Frequent Contributor
    Hi Leo,

    sorry about that.
    So if you want to copy only properties starting with/containing "c_", try this script:

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


    Regards,
    Marek
  • Hi Marek,

    Thank you for the solution. I will try that once I know where about the Project Setup Script located.

    I tried to find this Setup Script at Project level. All I got from Project level is as follows:

    Description,
    Properties,
    Load Script,
    Save Script,
    Report Script.

    Please advise for the location of the Project Setup Script.

    Many thanks,
    Leo
  • Cizo89's avatar
    Cizo89
    Frequent Contributor
    Hi Leo,

    no problem, please, see attached screenshot.

    Regards,
    Marek