-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests in separate test modules are performed twice by eunit command #2876
Comments
If you move your The issue comes from a weird interaction between how we track both source and test directories differently, and how deduping is currently done only on each set individually: rebar3/apps/rebar/src/rebar_prv_eunit.erl Lines 216 to 228 in 7ff5618
The deduplication is explicitly set up to remove the dupes between both directories, but not within any of them: rebar3/apps/rebar/src/rebar_prv_eunit.erl Lines 236 to 248 in 7ff5618
Rebar3 was built with the opinionated approach/expectation that a test-specific module should be in a test-specific directory, but still tries to support the test being co-located within the source file. We could argue that the de-duplication should go even deeper there, but it isn't clear, in a world where both src/ and test/ may exist, whether |
Thank you for the workaround pointer. I didn't realize Erlang has standard directory for test modules. I will use this directory from now on. I don't think test co-location within the module can ever go away since it is necessary when testing internal functions. I think, that for the purpose of running tests, it does not matter, if we consider the tests to test this or that module. What matters is that all relevant tests should be run and preferably only once since tests can be very time consuming. The result of a test does not change depending on our perception of its belonging. What tests should be run is dictated by EUnit. To test module |
Eunit allows extensive configuration of which tests to run. You may get the default behavior by specifying tests with
Which will ignore test directories and just run everything it can infer from the source files. |
I only just now realized Since |
Ok, I am sorry, that would work for applications, but not for modules, which would require duplication of EUnit functionality. I am just trying to wrap my head around the fact, that my management of application modules is ignored and irrelevant... |
I don't know, I barely use eunit anymore. The current approach supported by Rebar3 has been pretty much unchanged since 2015 when they were first supported, with the current filtering set done in 2016. Everybody else who has used EUnit with Rebar3 for the last 8 years has had mostly unchanged behavior. I don't think there would be harm in figuring out better ways to de-duplicate them to better handle the edge case you have here, but I'd be unlikely to consider it a good idea to majorly change how tests are scheduled. |
Environment
Project I discovered this in by chance is fairly big, but I managed to replicate it with this simple application:
rebar.config
src/p.app.src
src/p.erl
src/p_tests.erl
Current behaviour
All eunit tests located in separate modules (i.e. the modules with
_tests
suffix) are run twice.Here is result of running
reabr3 eunit
on the example application:Expected behaviour
Obviously, all the tests should run only once.
The text was updated successfully, but these errors were encountered: