Hi there! I'm quite new to Pants so maybe I'm miss...
# general
Hi there! I'm quite new to Pants so maybe I'm missing something but... On
you can use markers to run tests selectively. So maybe you want to 1st run all unit tests (quick, no services, etc). Then run tests that require a database and some local services. Then run tests that require external services/APIs. The idea being to not waste time testing some API client if some unit test will fail after it. The "normal" way is to use markers and run pytest one time for each. Another way is to sort all tests (across all modules) to run unit first, integration after. But I cannot see a way to leverage this in Pants (without messing around with environment variables). What is the "pants way" to run unit & integrations tests in separate goals?
Forget this question, I just ended up in: https://www.pantsbuild.org/docs/advanced-target-selection#tags-annotating-targets which kind of covers this.
You can also pass arguments to pytest directly, if you have existing markers you want to use, e.g.
./pants test :: -- -m integration_test
You can also name your files specially and filter by name. Like foo_test and foo_integration_test
Thank you for the tips. I'm testing both approaches. The first issue I see with both is that if I use coverage I cannot combine results? I can get the coverage report for the unit and integration runs, but each one shows its own independent result. Are there builtin facilities to combine coverage reports?
Pants does know how to combine coverage (it does so to merge coverage for all the tests in a single run)
but it doesn't do so across runs
It wouldn't be hard to add, but it would have to be some manual invocation I guess? I'm having a hard time figuring out how this should work across runs