Forum Discussion

LennSar's avatar
LennSar
Contributor
2 years ago

Fail Test Case only if it ENDS with failed Test Steps

Hi there,

 

I have a test case that runs a rest request up to 10 times. The first few iterations pretty sure will not meet the requirements of the smart assertion but at the 10th iteration it must do! My problem now is that by default ReadyApi consideres every TestCase a fail if one test step failed. Therefore I disabled the checkbox "Fail Test Case if it has failed Test Steps" in the test case option. Unfortunately the behaviour now is that the Test Case always passes even though my Test Steps fails at the 10th iteration after which it simply proceeds with the rest of the test case. 

 

What I'd like to have is the option that the test case results in a pass only when all Test Steps at the end of the Test Case are pass but each Test Step is allowed to fail inbetween. I'm pretty sure there is a solution to this and tha the answer is somewhere in the forum. I just couldn't find it.

Some additional info: I do the rerunning of the paticular test step either with a groovy script or a conditional goto. In Case of the groovy script I could manually fail the test case. In case of the Conditional Goto however this is not possible.

 

Any suggestion would be highly appreciated.

 

Thanks in advance!

 

Lenn

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Have a script assertion to achieve what you are looking for.

    Have a condition. If that condition is met then have the assertion.
    • LennSar's avatar
      LennSar
      Contributor

      Thanks for the suggestion. I don't quite understand how that would solve the issue. The script assertion as the smart assertion would fail the first couple of attempts and than would succeed. In a bad case both approaches would fail identically and without the enabled "Fail Test Case if it has failed Test Steps" option the test case would end up as a 'pass'. 

      Am I missing something?

      • nmrao's avatar
        nmrao
        Champion Level 3

        It is required to enable "Fail Test Case if it has failed Test Steps" in my suggestion.

        Sorry for not being clear earlier.

  • I still don't quite understand how that would differ from any other assertion. 

    A script assertion would decide between 'wrong' and 'right'. If  "Fail Test Case if it has failed Test Steps" is enabled a single 'wrong' detection would cause the test case to fail. A workaround would be to do nothing in the wrong case but that would result in a passing test case in case something really is wrong. 

    I could only imagine a script that implements the loop for sendin the rest request several times and do a final decission on the whole thing but that would be quite an effort compared to just adding a smart assertion ...