jeudi 28 janvier 2016

Run test function suite inside a ExUnit.Case synchronously

I know that, by default, a ExUnit.Case is synchronous (according to the docs http://ift.tt/1UsP2hf). I first thought that the functions inside this test where run synchronously but it seems that async make the entire test synchronous not the function inside.

When I run the test case the order of execution depends on luck. For the same call to

mix test --trace

the order of execution change. It is a problem for me because in a given test function I modify a global state with

Agent.update(...)

that the following test function rely on with

Agent.get(...)

And so I end up having sometimes my function test suite passes and sometimes not because Agent.get returns nothing since it is not set with Agent.update.

How can I have the execution order of my functions be conform to the declaration order in the file where they are defined?

Aucun commentaire:

Enregistrer un commentaire