cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to update a test suite property from groovy step that is in another test suite?

SOLVED
Highlighted
Contributor

Is it possible to update a test suite property from groovy step that is in another test suite?

In Test Suite A

  •   Test Case A
    • I have a groovy test step (in test suite A) that I want to update the value in a property of Test Suite B.

Test Suite B

 

Is this possible with groovy ? 

1 ACCEPTED SOLUTION

Accepted Solutions
Contributor

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

Thanks jsheph01 ... this is exactly what I was looking for !    

8 REPLIES 8
Contributor

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

This will update a test suite property from a groovy step. This must be run as a groovy step and not a groovy assertion as you do not have access to test runner.

 

def project = testRunner.testCase.testSuite.project
project.getTestSuiteByName("Test Suite Name").setPropertyValue("propertyName", "Property Value")
Community Hero

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

Thumb rule is to be able to execute each and every testcase independent.
Not sure of your use case, but better avoid dependency the way currently you have if at possible.


Regards,
Rao.
Community Hero

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

@nmrao 

 

I remember you saying before that testRunner isn't available in a script assertion - the Groovy Step snippet you provided is as follows:

def project = testRunner.testCase.testSuite.project
project.getTestSuiteByName("Test Suite Name").setPropertyValue("propertyName", "Property Value")

if I wanted this in a script assertion - would the following work?

 

def project = messageExchange.modelItem.testStep.testCase.testSuite.project
project.getTestSuiteByName("Test Suite Name").setPropertyValue("propertyName", "Property Value")

 

UPDATE TO TICKET: -  I confirmed the above does work in a script assertion, so I was going to delete this post - but there's no facility to delete my message  - so @nmrao - no need to answer the question fella - cheers.

 

Thanks man,

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Moderator

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

Thanks everyone for your participation!
@mpartyka, have you managed to find a solution? Did any of the replies help?


Olga Terentieva
SmartBear Assistant Community Manager

Contributor

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

Thanks for your suggestion.

 

def project = messageExchange.modelItem.testStep.testCase.testSuite.project

project.getTestSuiteByName("Test Suite Name").setPropertyValue("propertyName", "Property Value")

 

I copied into a groovy script test step

I replaced "Test Suite Name" with the name of one of my test suites

I replaced “propertyName” with the name of a property within that test suite.

The entire script now reads as follows:

-----------------------------

def project = messageExchange.modelItem.testStep.testCase.testSuite.project
project.getTestSuiteByName("RetrieveSecretsFromKeyVault").setPropertyValue("Token3", "xxx")

-----------------------------

I get the following error:  

groovy.lang.MissingPropertyException:No such property:messageExchange for class: Script5 error at line: 1.

 

 

Am I missing something ?  TIA for your help!

Contributor

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

Or did you mean to say " I confirmed the above does NOT work in a script assertion" ... confused as to why you would want to delete the post if it does work ?   Thanks again

 

Contributor

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

messageExchange will not work with a groovy script test step. If you want to use a groovy test step you will have to use testRunner (see my other post)

Contributor

Re: Is it possible to update a test suite property from groovy step that is in another test suite?

Thanks jsheph01 ... this is exactly what I was looking for !    

New Here?
Join us and watch the welcome video:
Watch the New Interview
APITestingMistake#2
Top Kudoed Authors