Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Test cases, test data and entry–exit criteria

How to write and use test cases, choose and manage test data, and decide when a test phase may start or finish (entry and exit criteria).

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Engineers use test cases and test data to verify that software meets requirements and to reproduce defects reliably. Entry–exit criteria give objective rules that decide when a testing phase can begin and when it can be declared complete, so teams do not stop too early or continue wasting time.

Key ideas

  • Test data — any data (values, files, network state, DB rows) used as input for executing test cases. Types: valid, invalid, boundary, representative production-like, masked/obfuscated for privacy. Good test data exercises normal, extreme and error cases. Derive test data using techniques such as equivalence partitioning, boundary value analysis, decision tables, state-transition testing, and pairwise/combinatorial testing.

  • Test suite — a set of related test cases grouped to test a feature or module. A test plan decides which suites to run and when.

  • Test script — an executable implementation of a test case (e.g., an automated script in Selenium or a shell script). A test case may be manual or automated; a test script is the automated artifact.

  • Test oracle — the mechanism to determine whether the observed outcome of a test is correct (could be expected result written in the test case, a reference implementation, or a database state). If no reliable oracle exists, testing is weak.

  • Entry criteria — a precise statement of conditions that must be true before starting a test level or activity. Example exact statement: "All planned test cases for the test level are designed and peer-reviewed AND the build to be tested is available AND critical blockers from the previous phase are closed." (Assumption: organisation requires peer review and a stable build.)

  • Exit criteria — a precise statement of conditions that must be true to stop testing at a level. Example exact statement: "All planned test cases executed AND (pass rate ≥ required threshold OR remaining open defects are only of minor severity and accepted by the product owner) AND test coverage ≥ required threshold AND no severity-1 defects outstanding." (Assumption: the organisation sets thresholds for coverage and defect status.)

  • Relationship and rules (state these like axioms used in exam answers):

    1. If entry criteria for a test level are not satisfied, that test level must not begin (rule of controlled start).
    2. Exit criteria define a stop-condition; testing may continue only if exit criteria are not satisfied.
    3. Entry and exit criteria must be measurable and traceable to requirements (so they can be verified). Also define suspension and resumption criteria: specify conditions to temporarily suspend testing (e.g., environment instability or multiple severity-1 defects) and the conditions to resume (e.g., environment stabilized and blockers fixed).
  • How to derive entry/exit criteria (step-by-step method often expected in exams):

    1. List the goals of the test level (unit, integration, system, acceptance). Refer to the course topic "Levels of testing" for objectives.
    2. For each goal, pick measurable artefacts needed to begin (e.g., code compiled, test cases reviewed). These become candidate entry criteria.
    3. For each goal, pick measurable outcomes that show success (e.g., pass rate, no open critical defects, percentage of requirements covered). These become candidate exit criteria.
    4. Review with stakeholders (dev, test lead, product owner) and set numeric thresholds where helpful.
  • Metrics commonly used to express criteria (definitions you must give in exams): test coverage (percent of requirements, statements, branches or other items exercised), pass rate, defect count by severity, execution progress.

  • Good practices:

    • Link every test case to one or more requirements (traceability). Draw a Requirement -> Test Case traceability matrix as part of test artifacts.
    • Keep test data versioned and environment-specific (use test data management tools for large projects).
    • Automate regression test cases (those run repeatedly) as test scripts.
  • Diagram you may be asked to draw (describe exactly):

    • Draw a flowchart with boxes: "Requirements" -> "Test Planning" -> "Test Design" -> "Entry Criteria met?" (decision diamond). From yes -> "Test Execution" -> "Exit Criteria met?" (decision diamond). From no on either decision loop back to the previous activity (e.g., if entry criteria no, go back to Test Design). Label each arrow and the diamonds with Yes/No.

Formulas

Test Coverage (%) = (Number of requirements covered by test cases / Total number of requirements) · 100

  • Number of requirements covered by test cases: count (no unit). Applies when coverage measured against requirements.

Pass Rate (%) = (Number of passed test cases / Total executed test cases) · 100

  • Used during execution to report quality of the current build.

Execution Progress (%) = (Executed test cases / Total planned test cases) · 100

  • Used to track how much of planned testing is completed.

Open Critical Defects = Total open defects where severity ∈ {S1, S2}

  • A count used in exit criteria. Severity categories depend on project policy.

Remember: test case template fields (syntax to remember) — ID | Title | Purpose/Description | Preconditions | Steps | Test Data | Expected Result | Postconditions | Priority | Author | Comments.

Worked examples

Example 1 — Write test cases and test data for a login form

Problem: A web login form has two fields: username (non-empty, max length 30) and password (non-empty). On success it goes to dashboard. On failure it shows "Invalid credentials".

Goal: Produce a small set of test cases (manual) that cover valid, invalid and boundary behaviour.

Test case 1: ID TC1 — Valid login

  • Preconditions: User exists with username "alice" and password "P@ssw0rd".
  • Test steps: 1) Enter username alice; 2) Enter password P@ssw0rd; 3) Click Login.
  • Test data: username="alice", password="P@ssw0rd".
  • Expected result: Dashboard page opens; user displayed as "alice".
  • Postcondition: User session active.

Test case 2: ID TC2 — Invalid password

  • Preconditions: User exists with username "alice".
  • Steps: Enter username alice, password wrongpass, click Login.
  • Test data: username="alice", password="wrongpass".
  • Expected result: Error message "Invalid credentials"; no session created.

Test case 3: ID TC3 — Empty username

  • Preconditions: none.
  • Steps: Leave username blank, enter any password, click Login.
  • Test data: username="", password="anything".
  • Expected result: Validation message indicating username is required (client-side).

Test case 3b: ID TC3b — Empty password

  • Preconditions: none.
  • Steps: Enter any username, leave password blank, click Login.
  • Test data: username="anything", password="".
  • Expected result: Validation message indicating password is required (client-side).

Test case 4: ID TC4 — Username length boundary

  • Preconditions: none.
  • Steps and data: username with 30 chars (valid), username with 31 chars (invalid). Run two subcases.
  • Expected: 30-char accepted, 31-char rejected with error.

Notes: Link each case to the requirement: e.g., R1: "username max length 30". This gives traceability.

Example 2 — Entry and exit criteria for system testing (model exam answer)

Task: Give a set of entry and exit criteria for system testing of an online store.

Answer (model):

  • Entry criteria (system testing may start when):

    1. All features implemented for the release have code complete status and are deployed to test environment.
    2. Integration tests passed or their critical defects are fixed (no outstanding P0/P1 integration blockers).
    3. System test plan and test cases for all planned features are prepared and peer-reviewed.
    4. Test environment configured with test data representing at least 80% of critical transaction types.
  • Exit criteria (system testing may be stopped when):

    1. All planned system test cases executed AND (pass rate ≥ 95% OR remaining failures are only of severity S3/S4 and accepted by the product owner).
    2. No open severity-1 defects.
    3. All high-priority regression tests are automated OR, if manual, are executed and passed.
    4. Test coverage against requirements ≥ 95%.

Explain: These criteria are measurable (pass rate, coverage, defect severity) and should be negotiated with stakeholders.

Worked numeric step (short): If Total planned test cases = 200, executed = 190, passed = 180:

  • Execution Progress = (190 / 200) · 100 = 95%
  • Pass Rate = (180 / 190) · 100 ≈ 94.74% (report as 94.7%). If exit requires pass rate ≥ 95%, exit criteria not met.

Common mistakes

  • Confusing a test case with an automated test script (test case is the specification; script is its implementation).
  • Using production data directly (privacy/security mistake) instead of masked/test copies.
  • Setting vague entry/exit criteria like "most tests passed" without measurable thresholds.
  • Forgetting to define the test oracle (how do you determine pass/fail?).

For your exam

Question types you will see:

  • Definitions (e.g., define test case, test data, entry criteria). A full-marks answer gives a short, exact definition and one-line example.
  • Short note (e.g., list fields of a test case template). Include the template and explain each field briefly.
  • Derivation/steps (e.g., how to derive entry/exit criteria). Show the 4-step method and give measurable examples.
  • Numericals (e.g., compute pass rate or execution progress). Show formula, substitute numbers, and compute with units (%).
  • Programs or traces (rare for this topic) — you may be asked to show test cases for a code snippet; give inputs, expected outputs, and show why they cover cases.
  • Diagrams (e.g., the flow of test process with entry/exit decisions). Draw the flowchart described under Key ideas.

What a full-marks answer includes:

  • Precise definitions with bold key terms (as required).
  • A complete test case example including preconditions, steps, test data and expected result.
  • Measurable entry and exit criteria with numeric thresholds or clear defect conditions.
  • A short example or calculation if asked for metrics.

Quick check

  1. What is a test oracle?
  2. Give three mandatory fields of a test case.
  3. How is Pass Rate calculated?

Answers: A test oracle is the mechanism that decides whether a test's observed outcome is correct; Mandatory fields: ID, Test steps, Expected result; Pass Rate = (Number of passed test cases / Total executed test cases) · 100.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?