← Workflows

阅读中文版本

Coverage Branch Target

Raise test quality: target branch coverage, quarantine flaky tests, and confirm the suite is deterministic and fast.

intermediate~30 mintestingqualityci

Objective

Make the test suite deterministic with branch coverage above the target and zero flaky tests in the main path.

Environment

  • A working testing environment with access to the target system and its tooling
  • Configuration and credentials for the testing workflow installed and verified
  • A rollback or undo path documented before any change is applied

Steps

1. Measure coverage gaps

Generate a coverage report and list the branches and error paths that are not exercised by any test.

Expected state: A gap list exists ranked by risk for the next test additions.

2. Quarantine flaky tests

Identify tests that fail intermittently, quarantine them in a separate suite, and file an issue for each.

Expected state: The main suite is green and flaky tests are tracked separately.

3. Verify determinism

Run the suite three times in a row on the same commit and confirm the results are identical.

Expected state: Three consecutive runs produce the same pass or fail result.

Decision points

Should flaky tests be deleted?

  • Quarantine and fix with an owner
  • Delete to keep the suite green

Quarantine and assign an owner; deleting hides the race condition and the coverage it provided.

Expected outcome

Make the test suite deterministic with branch coverage above the target and zero flaky tests in the main path. The change is verified and a rollback path is confirmed.

Verification

Make the test suite deterministic with branch coverage above the target and zero flaky tests in the main path. Compare before and after metrics and confirm the expected state is reached.

Cleanup

Archive the run artifacts, remove temporary credentials, and update the runbook with any changes.

Overview

Raise test quality: target branch coverage, quarantine flaky tests, and confirm the suite is deterministic and fast. The goal is to make the test suite deterministic with branch coverage above the target and zero flaky tests in the main path.

npx vitest run --coverage --coverage.branches=80

Steps

  1. Measure coverage gaps. Generate a coverage report and list the branches and error paths that are not exercised by any test. Expected: A gap list exists ranked by risk for the next test additions.

  2. Quarantine flaky tests. Identify tests that fail intermittently, quarantine them in a separate suite, and file an issue for each. Expected: The main suite is green and flaky tests are tracked separately.

  3. Verify determinism. Run the suite three times in a row on the same commit and confirm the results are identical. Expected: Three consecutive runs produce the same pass or fail result.

Verification

Confirm the outcome by checking: make the test suite deterministic with branch coverage above the target and zero flaky tests in the main path. Run the verification command and compare the result against the expected state. If any check fails, stop and investigate before continuing.

Decision points

  • Should flaky tests be deleted?
    • Quarantine and fix with an owner
    • Delete to keep the suite green
    • Recommendation: Quarantine and assign an owner; deleting hides the race condition and the coverage it provided.