Forum Discussion
rajs2020 : You can create setup script for the same. It will get executed only once and load all your data into the custom properties and you can use the data in subsequent test cases.
HimanshuTayal, nmrao - Could you please point me to the documentation for suite and test level setup? Does the suite level setup run only if you run the entire suite or does it also run if you run only one test ? I require both.
- richie4 years agoCommunity HeroHey rajs2020,
Using the approach i outlined would just be at testsuite level.
However you could alter my approach so it runs at testcase level (as you want) instead by not bothering adding an inital single "setup" testcase (that contains "Run testcase" step that executes the disabled "setup" testsuite) in the functional testsuites. Instead you would add the "Run testcase" step as the first step in each of the testcases in the functional testsuites.
E.g.
-Setup testsuite (disabled)
--Generate access token testcase
---Generate token RESTstep
---Property Transfer (xfers the access token to project level property)
-Functional testsuite (enabled)
--Create new record testcase
---Run testcase teststep (executes Generate access token testcase)
---Create new record REST step (that sources access token from project level property)
Using the above approach has the advantage that the "setup" testsuites arent executed by default until the functional testcases execute cos the setup testsuites are disabled. Also, having the Run testcase steps in each test or suite means that if the token expires before the end of the session it doesnt matter cos it is re-generated each time the testcase (suite) is run.
The above approach is what nmrao showed me a while back and Ive been using this approach ever since.
Ta
Rich- rajs20204 years agoFrequent Contributor
richie- I have some questions about your approach. I have shared an example below to help you better understand what I am trying to achieve. It am not sure if your test above approach will work like the example below.
The groovy script sets custom properties of TestCase1-Datasource which any other test case can use, for example the TestCase 1-DataUser, TestCase 2-DataUser, TestCase 3-DataUser etc. Contents of the script:// Set the outputs. context.testCase.setPropertyValue("output1", "v1"); context.testCase.setPropertyValue("output2", "v2");
I want the data source (i.e. TestCase1-Datasource) to run only one time when (1) I run the entire TestSuite2, OR (2) I run only one test in TestSuite2. Example - If I run TestSuite2, then TestCase1-Datasource is run only once. If I run only TestCase 2-DataUser, even then TestCase1-Datasource is run only once.
richie, nmrao, HimanshuTayal - Does this example give a better idea of what I am trying to achieve? Do you know how it can be done in ready api?Thank you.
- nmrao4 years agoChampion Level 31. Setup script at suite level works in the same way as test case. But just before beginning of the suite.
2. As per the screen shot, and script sample, I don't see any need for the separate suite / test case for that. The same script content be used for the Setup script for suite 2. Not sure though the sample script you gave is exact or does it have some changes.
3. If you need it to run in manner you desired, then it should not be at the test suite setup script. There can be other approaches to achieve.
Need to have more inputs what exactly the script is doing and is that contains anything specific to particular test? or is it common? what do you access in the Test case 2 (which was set in proposed setup script of suite)?
Related Content
- 11 years ago
- 12 years ago
Recent Discussions
- 5 days ago
- 9 days ago