--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/f6d66e30-e15c-4de3-a48c-321791a51de4n%40googlegroups.com.
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?
--
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-co...@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.
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.
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CALZj-Vp2YZRooJtB2oCd4HkHwHFBL9kXb6VapZFRPGV8j89XBw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/0E0554D5-3C7D-4650-B77B-53B2A158DC26%40a-corp.co.uk.
I think the point is that an exclusion group needs to be managed manually, which means if you add a new module you have to check every test to see if the module needs adding to an exclusion group there... which seems worse than just making the test async: false.
Worth pointing out (you may or may not know) you can pull your synchronous tests into their own module so the absolute minimum number of tests are running async which seems to be what you are after? Also that module can be in the same test file as a test module with async tests inside them.
To be clear, I understand and agree with the problem, but I don't agree with the solution because it is not ultimately solving the problem at hand. For example, speaking about Ecto, you could also use Mox, which also has an ownership-like mechanism, similar to Ecto's. You could define a behaviour, provide a default value for said behaviour, and then mock it in specific tests. This means your tests can run concurrently all the time. However, that sounds like overengineering for something as simple as reading the application environment. In any case, I hope it provides another frame of reference.
use ExUnit.Case, independent: [:db_case1, :db_case2]
mix test --exclude db_case1:true --exclude db_case2:true mix test --include db_case1:true mix test --include db_case2:true
On Fri, 26 Nov 2021 at 20:22, José Valim <jose....@dashbit.co> wrote:To be clear, I understand and agree with the problem, but I don't agree with the solution because it is not ultimately solving the problem at hand. For example, speaking about Ecto, you could also use Mox, which also has an ownership-like mechanism, similar to Ecto's. You could define a behaviour, provide a default value for said behaviour, and then mock it in specific tests. This means your tests can run concurrently all the time. However, that sounds like overengineering for something as simple as reading the application environment. In any case, I hope it provides another frame of reference.Quite right - I do in fact rely on fakes quite extensively to support tests, but many of the tests I'm considering are intended to test database queries, so I can't really fake them out. I honestly haven't yet looked in detail at Mox, so if it has some kind of checkout mechanism that could act as a semaphore, I suppose that could be a possible path to a solution (maybe a bit heavy), but as I said I'm not really looking to mock the global state, just serialise tests in groups according to the global resources they touch.
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CALZj-VpAEpeLGTD-de2nW6Gyyxew%2Bk%3De1GDJKWEkOMd9PKeXcA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KJpPPucGKJYffMxBT82nd5F4x640rEzwK86sokrR-Zgw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/6d006e1a-f653-482e-9704-607f4cda951e%40www.fastmail.com.
* if true, runs the tests asynchronously with other modules* if false, runs the tests synchronously with other modules* if an atom, runs the tests synchronously with modules in the same group (atom) and asynchronously with the remaining ones
The big question is: would we want the opposite? If an atom, runs the tests asynchronously with modules in the same group and synchronously with the remaining ones? And I would say that sounds doable too.
> async: true | false | {:async_within, :group} | {:async_outside, :group}
Best ideas I can come up with are async: {isolate: :group}, and async: {alongside: :group}, but not sure how much better that is.