Glossary · Testing fundamentals
Test case
Also called: test cases
Definition
A specific set of preconditions, input data, steps and expected results that verifies one behavior of the system and produces a clear pass or fail.
A test case is the smallest unit of planned testing: given these preconditions and this data, perform these steps, and expect this result. Anyone running it should reach the same verdict. Test cases are derived from test scenarios, requirements or acceptance criteria, and they are what gets executed, automated and reported on.
Example
| Field | Value |
|---|---|
| ID | TC-LOGIN-004 |
| Title | Login is rejected with a wrong password |
| Preconditions | Active user qa.user@example.com exists; user is logged out |
| Test data | Email qa.user@example.com, password WrongPass1! |
| Steps | 1. Open /login 2. Enter email and password 3. Click “Sign in” |
| Expected result | Message “Email or password is incorrect” is shown; user stays on /login; no session cookie is set |
| Priority | High |
| Requirement | AUTH-12 |
The same case as an automated Playwright test:
import { test, expect } from '@playwright/test';
test('login is rejected with a wrong password', async ({ page }) => {
await page.goto('/login');
await page.getByLabel('Email').fill('qa.user@example.com');
await page.getByLabel('Password').fill('WrongPass1!');
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByText('Email or password is incorrect')).toBeVisible();
await expect(page).toHaveURL(/\/login/);
});
Test case vs test scenario
A test scenario is a one-line statement of what to test (“verify login with invalid credentials”). A test case is how to test one specific instance of it, with exact data and expected results. One scenario usually produces several cases: wrong password, unknown email, empty fields, locked account.
What makes a good test case
- One behavior, one verdict. If a case can half-pass, split it.
- Specific expected results. “Error is shown” is weak; quote the message and state what must not happen.
- Independent. It sets up its own preconditions instead of relying on the previous case.
- Traceable. It links to the requirement or story it verifies.