On Fri, 26 Nov 2021 at 13:12, José Valim <jose.va...@dashbit.co> wrote:
> Why are tests that fake a global gen server running asynchronously? :) If > they change global state, how can you make sure in the long term, they are > not going to affect any other test in the system? > Well, I think the same question could be asked of any sync test file. A test will only really need to run sync if it affects global state in some way. An example from my current project is a NoSQL database that doesn't support transactions. Most test files only work with a single table, but if two test files use the same table, then I need those particular tests not to run simultaneously. They can run at the same time as all the _other_ tests just fine, though - many of those don't even touch the database. It seems like a generally sensible rule that tests that need to run sync also need to ensure that they restore or reset whatever global state it was that required them to run sync. For instance, if my test file has a setup function that calls Application.put_env() to change some global config (such as switching which genserver is used for a given task to a fake to support the test), then the config should be switched back again afterwards, or tests run after that point will fail. I think that's as true of the current situation with "async: off" as it would be with exclusion groups :) Paul -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CALZj-Vq5eJPCkoXYLhAn6O_vXTnLDO%2BhhwCSJT8JN4e7rTZhEw%40mail.gmail.com.