Ask a Question

How to set test case to OK by a script?

SOLVED
Jazz
Occasional Contributor

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?

9 REPLIES 9
nmrao
Community Hero

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.
Jazz
Occasional Contributor

That doesnt really help.

 

I add 2 attachements where u may see what i have and what is my target.

 

I cant add delay with constat time, beacose i never know, when web service finish his work and fall in green.

nmrao
Community Hero

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.
Jazz
Occasional Contributor

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

 

 

nmrao
Community Hero

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.
Jazz
Occasional Contributor

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.

nmrao
Community Hero

I was saying earlier that it needs to be in the test execution flow only based on some condition, can't explicitly do it which makes sensible as well. For eg: what any one gets by just change a failed to pass vice versa?


Regards,
Rao.
erickyi
New Contributor

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.

 

 

krabhishek_30
Occasional Contributor

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 ?

cancel
Showing results for 
Search instead for 
Did you mean: