Forum Discussion

danielmbanks's avatar
danielmbanks
Occasional Contributor
7 years ago
Solved

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!

  • 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", "");

3 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    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", "");
    • danielmbanks's avatar
      danielmbanks
      Occasional Contributor

      Thanks for a really simple solution. Works a dream!

      • groovyguy's avatar
        groovyguy
        Champion Level 1

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