I´ve some shared test cases that return data. Some days ago I´ve realized that, if the test fails, it is returning null instead of the value I give back.
If ‘text’ is ‘abc’ I see ‘Returned: 3’ in the log. But if I use ‘a’ as input text, the callTestCase is returning null instead of ‘1’ as I expected. Of course, inside the ‘log string’ test the size is showing right.
Can anyone help me? Is this a behaviour change of callTestCase return?
When you supply a as an input, then do you observe in the log size: 1 get printed out ? You mentioned that this could be a behavior change, does this mean on a previous version you didn’t have this problem, if so what version were you using ?
I tried to reproduce your case on my PC.
With text = ‘a’, the callTestCase returned 1 instead of null.
I could not reproduce your case. StepFailedException was thrown, and the callTestCase returned null.
As @ThanhTo explained below, this is known now behavior.
When I supply ‘a’ I see the size logged in the called test case but not in the returned var of the main test.
I have some test that sometimes, due performance requirements, are marked as failed but the functionality works. Those test are failing now. I´ve upgraded to the latest version (7.8.0) but still fails.
Since your child test case fails, Call Test Case keyword will throw a StepFailedException to the test case that calls it. Only when the test case is successfully executed will the value be returned. In this case, please change the failure handling of the verify statement to OPTIONAL.
CONTINUE_ON_FAILURE will indeed carry on the execution, but that test step will be marked as failed, while OPTIONAL will mark that test step as warning. A test case’s status is determined by the status of its final test step, so if the final test step is not failed or error, then the test case will be considered as passed.
You are right. If I mark the verification as optional, the return sentence works as expected. Of course, the test is marked as pass and I need a fail (it´s part of the continous development service).
If there is no way to avoid this behaviour, I think I´m going to need to adapt my tests.
Unfortunately I think there’s no way to change this behavior without changing a lot of design. If you assign the value to a global variable prior to the verification statement, you can bypass using the value returned from calling the test case, thus making the test fails. Then you can check the value in the calling test case.