Forum Discussion
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.
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)?
- rajs20204 years agoFrequent Contributor
nmrao- Here is an explanation for the photo for the project which I attached.
TestSuite1 > TestCase1 > Groovy script :This pulls "default test data" from a "data store" and stores them inside the test case custom properties. This test data can now be used by other tests. We want to read the data store only once.
TestSuite2 > TestCase 1 and 2 :
In both of these test cases, the first test step is to get part of the test data (not all of it) stored in the custom properties of TestSuite1 > TestCase1. To do that, the first test step of each test case in TestSuite2 will call TestSuite1 > TestCase1. For the remaining test data, test cases 1 and 2 can use auto generated values or hard coded values depending on what is being tested. The problem with this approach is that TestSuite1 > TestCase1 is called once for each test case in TestSuite2 which we want to avoid.
Here is my requirement - I wanted to ensure that TestSuite1 > TestCase1 is called only once if you run the entire TestSuite2 *OR* if you run only one test in TestSuite2. To do that, I had earlier copied TestSuite1 > TestCase 1 into TestSuite2 and made it the 1st test case. It will run once before all the tests if you run the entire test suite. But, the problem is that it will not run if you run only one test in TestSuite2. That is why I call TestSuite1 > TestCase1 inside each test case of TestSuite2.
I hope this clarifies. Thanks.- nmrao4 years agoChampion Level 31. still not sure of the contents of the groovy script to understand the issue (dont see the need for a separate suite / case)
2. can the logic of the script be executed conditionally? say, set a variable (custom property) once it is run. When it comes to second time, check the condition before executing the logic.
If the above does not help, is it possible to create sample soapui project which can help to reproduce the issue?
Related Content
- 6 months agoLearner_Pranavi
- 10 years agoRyan_Moran
Recent Discussions
- 15 hours agodipsthorat
- 19 hours agoisbiat
- 23 hours agoLea
- 2 days agoarmygrad