Hi I want to rerun the test with the same seed field if the test had been failed, so I need to somehow have access to seed inside of the test defspec. Is there any way to do this?
@tajoddin.shima defspec should print the seed when there's a failure, and I believe you can call the test function that defspec creates with a seed, like:
(defspec some-test ...)
(some-test 100 {:seed 42})
Yes but I want to run the test with "lein test" and my test scenario needs to rerun the wrong tests with the same seed again. so I want to get the seed exactly inside of test/defspec, Is this even possible? Thanks for your answer @gfredericks
@tajoddin.shima do you mean that you want to set the seed as an arg to lein test
somehow? or to have it hard-coded in your test-file somewhere?
none of them :)) I need something like this : @gfredericks
I don't understand that; it looks like an infinite recursive loop
Like, if the test fails, you just want to run it again?
I have some randomness out of test-check context in my generator I save the number of recursion in an atom and control this. I just want to make sure that when the test failed is because of randomness inside of my generators
would it work to run the individual trial multiple times instead of the whole run?
something like
(prop/for-all [test-suite (generator)]
(loop [failures-left 5]
(or (actual-test test-suite)
(and (pos? failures-left) (recur (dec failures-left))))))
exactly just instead of test-suite inside the loop, each time generate the new suite with the same seed
with generating the suite with same seed I want to bound the randomness to something that comes from out of test-check context
This extra randomness is used in the generator?
yes
what about this? It would be enough that I have access to the seed inside of the defspec to save in DB and don't need to regenerate the test-suite in it.
I wonder whether you need the extra randomness at all That's the nonstandard part What is it accomplishing?