Skip to main content

Test Case

In Turkish
test senaryosu
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/test-case

In short

A test case is a check of one specific behavior: starting conditions, input or steps, and the expected result that shows if the software behaves correctly.

What is a test case?

A good test case is precise enough that anyone, or any machine, can run it and agree on the outcome. For a login form it might read: given a registered user, when they enter the correct email and a wrong password, then an error message appears and they stay logged out. Manual test cases are often written in a test management tool with an ID, preconditions, steps and expected results.

In automated tests, each test function is a test case, and related ones are grouped into a test suite. The Arrange, Act, Assert pattern keeps them readable: set up the data, perform one action, then check the result. Each case should test one thing and have a name that explains it, such as rejects_expired_coupon, so a failure tells you immediately what broke.

Choosing cases well matters more than writing many. Cover the normal path, invalid input, empty and very large values, and the boundaries where behavior changes, such as exactly 18 years old for an age check. Bugs cluster at those edges, which is why techniques such as boundary value analysis and equivalence partitioning exist.

A common misconception is that more test cases always mean better testing. Dozens of cases that check the same happy path add maintenance without finding new bugs. A smaller set that covers distinct behaviors, edge cases and past regressions gives far more confidence.

Key takeaways

  • A test case checks one behavior with conditions, steps and an expected result.
  • Related test cases are grouped into test suites.
  • Arrange, Act, Assert keeps automated test cases readable.
  • Good cases cover errors, edge cases and boundaries, not only the happy path.
  • Distinct, well-chosen cases beat a large number of similar ones.

Example

Test cases with Arrange, Act, Assert (pytest)python
import pytest
from shop.coupons import apply_coupon, CouponExpired

def test_applies_ten_percent_coupon():
    cart = {"total": 200}                        # Arrange
    result = apply_coupon(cart, "SAVE10")        # Act
    assert result["total"] == 180                # Assert

def test_rejects_expired_coupon():
    with pytest.raises(CouponExpired):
        apply_coupon({"total": 200}, "SUMMER2024")

@pytest.mark.parametrize("total", [0, 0.01, 999_999])   # boundaries and extremes
def test_never_goes_below_zero(total):
    assert apply_coupon({"total": total}, "SAVE10")["total"] >= 0

Readers ask

What is the difference between a test case and a test scenario?

A test scenario is a high-level idea of what to test, such as checking login. Test cases are the specific checks within it, each with exact inputs and expected results, such as a wrong password or an expired account.

What should a test case include?

An identifier or clear name, preconditions, the steps or input, the expected result and, once run, the actual result. Automated cases express the same parts in code.

What is an edge case?

An input or situation at the limits of what the software handles, such as an empty list, the maximum allowed value or a leap day. Edge cases deserve their own test cases because bugs often hide there.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings