How to set test case to OK by a script?
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to set test case to OK by a script?
Hello
In my test case, i have test step, that may fall in failed (red) state. In that case, i use script to wait few minutes and re-run test step again. (Beacose web service needs a little time before he process infromation from previous web services)
Im doing this until test step switch to OK (green) state, in that case I normaly continue throught rest of test case.
But when my test step switch to OK, the test case still stay in failed (red) state.
So can i set test case to OK (green) state by a script? How?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure how exactly your tests are designed and executed. But one thing is sure in such scenario, use "Conditional Goto" step. Otherwise, execute the step that you think it requires time delay by adding a delay step.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two options(conditional goto or delay) I mentioned earlier, based on the context, choose appropriate one which suites your case.
Agree that you do not know the outcome/span of time, but there should be some kind of SLA that the operation would get finished. Otherwise, if you are getting some kind of status, then it should be only failed based on some response data by the use of assertions. Little wonder if you don't have such situation.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, cond. goto may be used for this situation.
Answer to to original question is: So i cant set test case to OK by a groovy scipt?
Thnx
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Of course, you can do.
But you have to have a case for the same when you want to make it fail or pass.
Here the groovy script which demonstrates the same -
Condition - if even number then fail, pass otherwise.
Create a test case with a groovy script test step and add below code, and try to run the test case and see.
import com.eviware.soapui.model.testsuite.TestRunner.Status if ((new Random().nextInt(9))%2 ==0) { testRunner.status == Status.FAILED } else { testRunner.status == Status.PASSED }
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Status.PASSED doesn't exists -> https://www.soapui.org/apidocs/com/eviware/soapui/model/testsuite/TestRunner.Status.html
And when scipt go throught Status.FAILED tree, my test case finished as green (OK).
But in base of your hits a search a little more on google, and I think that I can't change status of running Test Suite/Test Case back to OK from FAILED.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From my investigation, depending on the type of the test step, if it is a groovy test step, you can change the status to FAILED (red icon) but there are no icons for any other status (I peeked into jar file to confirm). Hopefully the developers would add the feature to support colored icons for groovy steps. For other test type of test steps, e.g. REST based or SOAP based, using the assertions will change the colors.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rao,
So this is my use case :
- Keep checking the status of a test step until it returns true (until the case passes).
- Each time it'll wait for 5 seconds before checking again. If the case passes, move to another steps
The problem i am facing is, if the case fails even once, this test case is marked as FAILED. So, when i run this test case from Jenkins, it shows as failed even when all the test steps have passed.
So this line that you have provided "testRunner.status == Status.PASSED" does not work. Looking at the documentation here, i do not see PASSED as a status.
Do you have any other solution to marking the status as Passed ?
