[Cuis-dev] Tests

Juan Vuletich juan at cuis.st
Tue Aug 16 16:58:27 PDT 2022


On 8/16/2022 2:01 PM, Luciano Notarfrancesco via Cuis-dev wrote:
> Hi Juan,
>
> On Tue, 16 Aug 2022 at 20:16 Juan Vuletich <juan at cuis.st 
> <mailto:juan at cuis.st>> wrote:
>
>     Besides, any test I
>     write is repeatable, setting Random seeds as needed. I guess you must
>     have your reasons to do otherwise...
>
>
> You set a fixed seed in the test method itself? In that case you run 
> the exact same test every time.

Yes. I always thought it is best to make tests deterministic. A tests 
that sometimes passes and sometimes fails sounds like a headache!

> But what I do is set a ‘seed’ instance variable to a randomly 
> generated value in initialize, and in setUp I set a ‘random’ instance 
> variable to ‘Random seed: seed’. This is essentially what Leandro 
> implemented in Bee (he added a ‘seed’ instance variable to TestCase). 
> In this way, test methods can use ‘random’ freely and all is 
> reproducible, but the seed is not fixed (if I create a new test suite 
> or press the refresh button on the test runner new seeds are used, and 
> on the long run a much larger space is covered in the tests).
>

I see. You need to be careful when a test fails. Perhaps it would be 
best to also include a list of seeds to always be included, and when a 
test fails, you add that seed to the list. This way, it is still useful 
as a regression test (as deterministic tests are).

Cheers,

-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20220816/85b8be13/attachment.htm>


More information about the Cuis-dev mailing list