Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Salesforce QA / Tester
medium

How do you write effective test cases?

Effective test cases are clear, comprehensive, and maintainable.

Structure:

  • ID: unique identifier (TC-101).
  • Title: brief description.
  • Module / feature: what's being tested.
  • Pre-conditions: state before testing.
  • Test data: specific values needed.
  • Steps: numbered, specific actions.
  • Expected results: what should happen.
  • Actual results: filled during execution.
  • Status: Pass / Fail / Blocked.
  • Severity / Priority: importance.

Principles:

1. Specific and observable.

  • "User clicks Save button" — clear.
  • "User makes changes" — vague.

2. One thing per test.

  • Single objective.
  • Easier to debug failures.

3. Cover happy path AND edge cases.

  • Standard flow.
  • Boundaries (max field length, zero values).
  • Negative cases (invalid input).
  • Concurrency (multiple users).
  • Error scenarios.

4. Independent.

  • Tests don't depend on each other.
  • Each can run in isolation.

5. Repeatable.

  • Same input -> same output.
  • Test data created/cleaned within test.

6. Maintainable.

  • Use shared resources (test data factories).
  • Don't duplicate logic.
  • Update as features evolve.

7. Use Gherkin / Given-When-Then format for behavior:

Given a Lead with Status = Working When user clicks Convert Lead Then Account, Contact, Opportunity are created And Lead Status = Converted

Readable for business stakeholders too.

Coverage strategy:

  • Equivalence partitioning — group similar inputs.
  • Boundary value analysis — test edges (0, 1, max-1, max).
  • State transitions — test all stage transitions.
  • Error guessing — based on experience.
  • Use case scenarios — end-to-end paths.

Common pitfalls:

  • Vague test cases — "test login" tells you nothing.
  • Massive test cases — 50 steps, hard to debug.
  • No expected results — "user does something" without expected outcome.
  • Outdated test cases — system changed; test wasn't updated.

Senior QA insight: good test cases are documentation. Future testers should be able to execute without prior knowledge.

The senior framing: writing test cases is harder than executing them. Investment in good test cases pays back across many runs.

Why this answer works

Senior. The structure and Given-When-Then format are mature.

Follow-ups to expect

Related dictionary terms