This is a tool to help you run only the tests that have changed since the last successful test run, instead of re-run all the tests every time.
As the project grows, more and more tests are added. It makes the time to run all the tests increase dramatically.
As your team grows, more and more times your team and your CI need to run the tests.
Especially on CI, we normally clean and re-run all the tests, regardless of the changes.
With spm-selective-testing
, we can run only the tests that have changed since the last successful test run, significantly reducing the time to run the tests. 🚀
As mentioned above, selective testing can run only the tests that have changed.
So what are tests that have changed?
A test target is marked as changed if its dependencies or it's source code has changed.
For example, assuming the following dependency graph:
FeatureA has tests FeatureATests, and depends on Core FeatureB has tests FeatureBTests, and depends on Core Core has tests CoreTests
Action | Description |
---|---|
FeatureA source code changed | Only FeatureATests is marked as changed |
FeatureB source code changed | Only FeatureBTests is marked as changed |
Core source code changed | FeatureATests, FeatureBTests, and CoreTests are marked as changed |
- Your project is using SPM & Modular architecture
- Your project is using Test plan to organize tests
You can go to GitHub Releases page to download the release executable program (This project is still in the development phase, and not ready for production.)
// Init a default configuration for your project
spm-test-selective init
// Perform selective testing
spm-test-selective $PROJECT-PATH $TEST-PLAN-PATH
- Find all SPM modules in the project
- Generate hashes for all SPM modules
- For each module, compare its current hash with its cache hash.
- If any module's hash is different from its cache hash, add that module to the test plan. Otherwise, disable that module in the test plan.
- Run tests with the test plan.
- If run tests successfully, update the cache.
Feel free to open new issues/feature request/merge request