test-check

2019-06-10T06:48:47.000200Z

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?

2019-06-10T10:30:47.001200Z

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

2019-06-10T12:33:16.001600Z

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

2019-06-10T12:34:59.002400Z

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

2019-06-10T12:41:02.002500Z

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

2019-06-10T12:43:09.003400Z

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

2019-06-10T12:43:31.004100Z

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

2019-06-10T12:46:37.004300Z

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

2019-06-10T12:47:45.004800Z

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

2019-06-10T12:48:58.006300Z

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

2019-06-10T12:52:08.006600Z

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

2019-06-10T12:54:11.006800Z

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

2019-06-10T13:01:54.007300Z

This extra randomness is used in the generator?

2019-06-10T13:03:28.007600Z

yes

2019-06-10T13:04:42.008700Z

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.

2019-06-10T13:05:50.009400Z

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