Ask a Question

Dynamic property means project XML changes after every run

SOLVED
danielmbanks
Occasional Contributor

Dynamic property means project XML changes after every run

The situation:

I have 1 test case (TC1) that dynamically creates a property (imagine a property received from a database, rest call, random number generator, etc.) and a 2nd test case (TC2) that uses the "Run TestCase" step to call TC1 and use the dynamic property as part of its test.

 

The problem:

Whenever I run the test (TC2) and save the project, the value of the property retrieved from TC1 is saved. If this is a truly dyanmic number like a random number then this means that every time I run the test and save it, my project XML will have changed. This is obviously a problem when committing to Git and seeing lots of irrelevant changes.

 

The question:

Is there a way of achieving the same set-up without creating these diffs?

 

I have attached a small example project that shows what I'm talking about, hopefully it'll help.

 

Cheers!

3 REPLIES 3
groovyguy
Champion Level 0

If you don't want to save this property, you can use either a groovy script test step at the end of your TC2, or a tear down script, that NULLs this data after running if all tests passed. 


Here's a sample groovy script:

 

context.testCase.testSteps["Run TestCase"].setPropertyValue("propFromTestCase1", "");



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
danielmbanks
Occasional Contributor

Thanks for a really simple solution. Works a dream!

I am glad it worked. I had similar issues to contend with so I'm glad I was able to provide a solution. 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
cancel
Showing results for 
Search instead for 
Did you mean: