Fork me on GitHub
#test-check
<
2019-06-10
>
Shima06:06:47

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?

gfredericks10:06:47

@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})

Shima12:06:16

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

gfredericks12:06:59

@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?

Shima12:06:02

none of them :)) I need something like this : @gfredericks

gfredericks12:06:09

I don't understand that; it looks like an infinite recursive loop

gfredericks12:06:31

Like, if the test fails, you just want to run it again?

Shima12:06:37

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

gfredericks12:06:45

would it work to run the individual trial multiple times instead of the whole run?

gfredericks12:06:58

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))))))

Shima12:06:08

exactly just instead of test-suite inside the loop, each time generate the new suite with the same seed

Shima12:06:11

with generating the suite with same seed I want to bound the randomness to something that comes from out of test-check context

gfredericks13:06:54

This extra randomness is used in the generator?

Shima13:06:42

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.

gfredericks13:06:50

I wonder whether you need the extra randomness at all That's the nonstandard part What is it accomplishing?