BenWoodworth / Parameterize

Kotlin syntax for clean parameterized code
Apache License 2.0
37 stars 3 forks source link

Change default `onFailure` to not catch failures #21

Closed BenWoodworth closed 9 months ago

BenWoodworth commented 11 months ago

Outside of testing contexts, behaving the same as a normal loop and not handling failures should be the default behavior.

Having parameterize continue looping means pressing forward for any failure, even Errors which are not meant to be caught normally. Additionally, having the default onComplete behavior be to throw a ParameterizeFailedError is problematic for the same reason. With that and the additional overhead of recording failures and parameter arguments, the current default behavior in v0.2 isn't suitable for normal use in code.

Changing the default behavior to throw immediately from onFailure means the default parameterize acts identically to a nested for loop, with Errors not being caught, no additional failure recording overhead, and no errors thrown (since throwing from onFailure terminates parameterize without onComplete being executed).

For testing, this is fine since there are two main styles of usage I see. Annotation-based, like kotlin.test/JUnit, and DSL based like Kotest.