Forum Discussion

vpachpute1's avatar
vpachpute1
Frequent Contributor
8 years ago
Solved

How to set TestSuite Properties for specific suite name from Groovy

Hi

 

Currently I am using this

testRunner.testCase.testSuite.setPropertyValue("SpendLimit_Mon", spendlimit_mon);

 

But this only sets for the current test suite.

 

I want to specify name of test suite so that my script will set property for any target test suite.

I have tried this. But not worked.

testRunner.testCase.testSuite.name("SpendLimits").setPropertyValue("SpendLimit_Trans", spendlimit_Trans);

 

Can anyone please help me on this.

 

Regards

Vishal

  • Hi Vishal,

     

    You are almost there. You need to get the project object and then use any of this:

    project.getTestSuiteByName("name")
    project.testSuites["name"]
    project.testSuites."name"

     

    So inside a test case you would use:

    testRunner.testCase.testSuite.project.testSuites["SpendLimits"].setPropertyValue("SpendLimit_Trans", spendlimit_Trans);
    // or
    testCase.testSuite.project.testSuites["SpendLimits"].setPropertyValue("SpendLimit_Trans", spendlimit_Trans);

    From a test suite script:

    testSuite.project.testSuites["SpendLimits"].setPropertyValue("SpendLimit_Trans", spendlimit_Trans);

    From a project script:

    project.testSuites["TestSuite"].setPropertyValue("SpendLimit_Trans", spendlimit_Trans);

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Vishal,

     

    You are almost there. You need to get the project object and then use any of this:

    project.getTestSuiteByName("name")
    project.testSuites["name"]
    project.testSuites."name"

     

    So inside a test case you would use:

    testRunner.testCase.testSuite.project.testSuites["SpendLimits"].setPropertyValue("SpendLimit_Trans", spendlimit_Trans);
    // or
    testCase.testSuite.project.testSuites["SpendLimits"].setPropertyValue("SpendLimit_Trans", spendlimit_Trans);

    From a test suite script:

    testSuite.project.testSuites["SpendLimits"].setPropertyValue("SpendLimit_Trans", spendlimit_Trans);

    From a project script:

    project.testSuites["TestSuite"].setPropertyValue("SpendLimit_Trans", spendlimit_Trans);
    • vpachpute1's avatar
      vpachpute1
      Frequent Contributor

      Hi 

       

      Thanks very much for your reply.

       

      Solution worked perfectly for me.

       

      Regards

      Vishal