Skip to content
BENIBIX Learn

Test Case

Development🧪 Testing & QualityTest Basics

Also known as Test, Test Scenario

One check in a test. It has a set input and a result you expect.

Think of it like

Think of it like one question on a quiz. It has one right answer.

Example

Jack writes three test cases for his login. One has the right password, one the wrong one, and one an empty box.

Why it matters

Clear test cases turn a vague hope that it works into checks a computer runs each time.

Definition

A test case is one check: a set input, the steps to run and the result you expect. Adding 2 and 3 should give 5 is a test case. Each one is named for the thing it checks, so a failure tells you what broke. A good test case checks one thing, so it fails for one reason. Many test cases together make a test suite.

Example code

python
def test_total():
    assert total([2, 3]) == 5
One test case: the total of 2 and 3 should be 5.

Common mistake

Packing many checks into one test case. When it fails, you cannot tell which part broke.

Key takeaways

  1. 1
    Input, steps, result. The three parts.
  2. 2
    One thing each. One reason to fail.
  3. 3
    Named for what it checks. The name explains the fail.