A team has a suite of L2 functional tests that run against a SQL database in its CI pipeline. One test creates customer records and leaves them in the database. Another test assumes that the customer table is empty, and it fails whenever it runs after the first test.
Requirements:
- The team wants to run the suite in parallel to shorten the pipeline.
- The tests must continue to exercise a real SQL database.
- Results must not depend on the order in which the tests run.
What should the team change in its testing strategy for this suite?
The tests interfere because they share mutable database state. Giving each test a separate SQL database with a known starting state provides control over its environment and prevents interference between concurrent tests. This supports parallel, order-independent execution while preserving testing against SQL.
- Correct: Give each test a separate SQL database initialized to a known state. The source requires functional tests to control their environment and begin with known state. Separate databases prevent tests from modifying one another's state, supporting the independent execution described in the source while retaining SQL coverage.
- Not correct: Configure the pipeline to retry automatically any functional test that fails. Retries do not establish the isolated, known starting state required by the source. Records left by another test can still cause a retried test to fail.
- Not correct: Replace the functional tests with L0 tests that mock the database layer. The source describes L0 tests as fast, in-memory unit tests. Mocking the database removes the real SQL dependency that this suite must retain.
- Not correct: Configure the test runner to execute the tests one at a time in a fixed order. A fixed sequential order preserves the dependency between tests instead of providing the independence described in the sources, and it prevents the required parallel execution.
- Shift testing left with unit tests - Azure DevOpsMicrosoft Learn
- Configure and Provision Environments: Understand Shift-leftMicrosoft Learn