Hey all! I have integration tests that spin up clo...
# general
s
Hey all! I have integration tests that spin up cloud infra, then run tests using the newly created resources. These typically take 10+ minutes. What's the recommended way to approach these kinds of tests with pants? It seems pants works much better with unit tests, interested to hear best practices for integration testing.
c
I'm not sure how "good" a practice this is, but I have a process that uses both pants tags and pytest marks. All my integration tests are marked with "integration", and I have a separate
python_tests
targets that specifically pull in
integration_test.py
and is tagged "integration"
Copy code
python_tests(
	name="integration-tests",
	sources=["integration_test.py"],
	tags=["integration"],
)
I can then do fun things like have pytest automatically skip integration tests. Or you can have pants run (or skip) integration tests, either at the pants level (
pants --tag="integration" test ::
) or at the pytest level
pants test :: -- -m "integration"
. You probably only need one of those, but I like the flexibility. There are a few advantages one way or the other. Skipping with pytest is annoying because you can end up with collection errors if all tests are deselected and you need to add a fake empty test.
👍 1
s
Tagging looks excellent! I'm wondering if we could maybe use the bash script targets to setup tests first, also like your approach!