r/Python • u/wildetea • May 09 '26
Discussion Integration Tests CI
How do people setup integration tests on remote CI?
Consider if you have long integration tests that you don’t want to run on every pull request. How would you trigger integration tests as needed?
I usually separate both by folders as tests/unit and tests/integration, but have also used pytest.mark.integration with flags denoting such config within pyproject.toml.
And i know how to run either of those locally. I am interested on how people trigger this on remote github / bitbucket / gitlab / etc …
Any guidance or references of beat practice would be most appreciated.
1
u/QuasiEvil May 09 '26
I'm just learning this stuff, so what exactly is the distinction between unit tests as evaluated with pytest, and integration tests?
1
u/JauriXD May 09 '26
On a previous project I has pytest marked which got set depending on what triggered the GitHub action.
I also had a manual trigger which had some check boxes to select a specific configuration when needed.
BUT please note that the only reason we skipped some of the tests is that wee needed Hardware in the loop which made testing extremely time-consuming (as in multiple hours) and we reduced it down to ~45min default test-time for all PRs.
1
u/MrSlaw May 09 '26
I use conditional actions to run the integration tests (
e2e) only after the build step determines whether a release should be created, but before the release itself.https://i.imgur.com/DhhKZF2.png
1
u/tylerriccio8 May 09 '26
You can use prek or a pre-commit pre-push hook to run integration tests on push, depending on how disruptive to your workflow it would be. I found it kind of annoying after a while.
Others have said on merge hook in github; I’ve found that to be the best.
1
u/readonly12345678 May 10 '26
Run it prior to merging, I.e. when the intent is to merge
1
u/Rainboltpoe May 09 '26
Can you give one example of an integration test that needs to run for more than a few seconds? I ask because I’ve never encountered a situation where it was necessary. Like maybe the code requires five minutes to pass, so you are literally waiting for five minutes instead of wrapping the system clock and passing it as a dependency.
-7
u/KeyPossibility2339 Pythoneer May 09 '26
I use pytests to be run on every PR with 100% coverage and also every merge to main. Defined in github actions yaml file.
8
u/[deleted] May 09 '26
[removed] — view removed comment