Hi Devs, I work a lot with property tests and use ...
# kotest-contributors
a
Hi Devs, I work a lot with property tests and use the
checkAll
function. I would really like to add a change to call
beforeTest
and
afterTest
(or some other equivalent functions) between each iteration of the property base tests. Looking at the code I was trying to find a central place of where to add such call. I found this function
proptest
but there are many of them and I don’t have access to the Spec from there. The Spec holds the before and after functions. I wonder if someone more familiar with the code can guid me here. Thank you
s
Someone already asked for the same thing actually https://github.com/kotest/kotest/issues/1435
We can't hold into anything from the spec itself, because the property test framework has to be usable from outside Kotest Framework. People use it with JUnit for example.
I would suggest we add a new PropTestProjectConfig object which people can call .beforeTest and .afterTest to register callbacks.
a
That sounds good @sam. Any idea where to start?
I actually came out with a wrapper. not sure it is the best idea though…
s
If you want to work on it, then I suggest you add a new
object PropTestPropertyConfig
object. Two methods in there,
beforeCheck
and
afterCheck
which accept a lambda each. Add those lambdas to a list. Inside checkAll and forAll they should call PropTestPropertyConfig.before to get the list, and execute them.
a
oh… I will have a look. Thank you.