spock icon indicating copy to clipboard operation
spock copied to clipboard

Allow to run in strict mode. Fail if any exception is thrown while polling.

Open jsalinaspolo opened this issue 6 years ago • 5 comments

Using PollingConditions might hide some errors while invoking the closure.

Adding a log.error might help to discover that an even that the test passed, an exception occurred.


This change is Reviewable

jsalinaspolo avatar Apr 22 '19 22:04 jsalinaspolo

Hi, spock has no logging library at the moment, this is not an accident. Furthermore, you already get the error as the cause of the SpockException so I don't see a great gain here.

leonard84 avatar Apr 23 '19 14:04 leonard84

Hi, The reason was to avoid having to wrap the closure within a try/catch each time or to create our wrapper on PollingConditions.

If you do not see a gain, feel free to reject it. Might be a good reason to do not add logging.

jsalinaspolo avatar Apr 23 '19 16:04 jsalinaspolo

Having a second thought. You might have noticed that the SpockException is only thrown when the time elapsed times out. If intermediate iterations fails with any exception then it will be hidden when an iteration success. In our case, we would like to know if have been any exception different than the assertion.

Instead of logging, would you prefer to have a config parameter to be unexceptional and fail the eventually if exceptions different than the assertion are thrown?

jsalinaspolo avatar Apr 23 '19 16:04 jsalinaspolo

Hm, having something akin to https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/spock/lang/Retry.java#L47-L54 as property for PollingConditions would be ok.

Please be aware, that we won't merge anything until 2.0 branch is green.

leonard84 avatar Apr 23 '19 17:04 leonard84

@leonard84 Let me know if you think that passing a parameter to run it on strict mode looks a good approach?

jsalinaspolo avatar Apr 24 '19 21:04 jsalinaspolo