Right, my concern is not about the existing tests, which indeed need to
revert, but future changes. Taking the application environment example, now
anyone in the future that adds a feature that reads from that environment
or writes a test that reads from that environment, they need to remember to
annotate their new test case to exclude a completely unrelated file, that
may have been written 1 week, 1 month, or 1 year ago.

On Fri, Nov 26, 2021 at 3:17 PM Paul Dann <pdgid...@gmail.com> wrote:

> 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
> <https://groups.google.com/d/msgid/elixir-lang-core/CALZj-Vq5eJPCkoXYLhAn6O_vXTnLDO%2BhhwCSJT8JN4e7rTZhEw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAGnRm4%2BoWx08e5h3KFqg%3Die9HOO2-W2MBGvOKOB%3DC6X6T2knTw%40mail.gmail.com.

Reply via email to