Understanding how test dependencies work in Spur
Test dependencies in Spur allow you to define relationships between tests and control their execution order. This page explains the different dependency modes and provides detailed examples of how they work.
Sequential dependencies ensure tests run in a specific order, where each test waits for its predecessor to complete before starting. This is useful when tests have a natural progression or when later tests depend on the state created by earlier ones.
Sequential Dependencies Example
In sequential mode:
Tests run in the order specified by the dependency arrows
If a test fails, subsequent tests will not run (except for teardown tests)
Each test must complete before the next one begins
This ensures data consistency and proper state management between tests
Layer-based dependencies organize tests into layers, where all tests in one layer must complete before any tests in the next layer can begin. This is particularly useful for complex test scenarios with parallel execution requirements.
Layer-based Dependencies Example
In layer-based mode:
Tests are organized into numbered layers (Layer 0, Layer 1, etc.)
All tests within a layer can run in parallel
A layer must complete all its tests before the next layer begins
This enables efficient test execution while maintaining necessary dependencies
Teardown tests are special tests marked to run at the end of a test suite, regardless of whether previous tests succeeded or failed. They are crucial for proper cleanup and resource management.
Key features of teardown tests:
They run even if previous tests in the sequence fail
Typically used for cleaning up resources or reverting changes
Help maintain a clean state between test runs
Ensure proper resource cleanup even after test failures
Resource Cleanup:
Deleting test data
Removing created users
Closing connections
Reverting system changes
Organize Dependencies Logically
Group related tests together
Keep dependency chains as short as possible
Use layers for tests that can run in parallel
Use Teardown Tests Effectively
Plan Your Test Structure
Consider dependencies during test design
Review and optimize test execution order
Monitor and Maintain
Optimize for execution time
Remove unnecessary dependencies