Forum Discussion
This is because each TestCase has its own TestCaseRunContext, and so your TESTCASE1 is not looking at the same list as TESTCASE2.
When a TestSuiteRunner kicks off a TestCase, it copies the entries in the TestSuiteRunContext to a new TestCaseRunContext to run the test. So both test cases are looking at copies of the original values from the TestSuiteRunContext.
In the case of the List, a reference to an instance of a List is copied, so its the same object. But for primitive types, the value is copied.
You can access the TestSuiteRunContext directly instead, so that you having the same objects. Like this:
def testSuiteContext = context.get("#TestSuiteRunner#").getRunContext()
Just remember that this won't exist if you run your Test Case or Test Step by itself instead of by running the Test Suite.
- SR16 years agoOccasional Contributor
Thanks for your reply Sir. Good answer. So If i want to share&update the primitive types between testcases, can i have the primitive values as members in a class and create a object in testsuite context and update the members in different testcases? will it work? object will be reference copied or value copied? please advice.
Related Content
- 4 years ago
- 6 years ago
- 10 years ago
- 8 years ago