Classification Trees are a structured, systematic method for designing test cases by decomposing complex inputs into features and categorising them. This method ensures comprehensive, meaningful coverage of the input space, beyond random sampling.

Definitions

  • Test Object
    • The test table input instance (e.g. a date composed of a year, month, and day is a testable input instance)
  • Classification
    • A category or dimension of input or system condition that is relevant for testing.
  • Classification Tree
    • A tree structure where the root represents the test object or function under test
    • The first-level nodes are classifications
    • The leaf nodes under each classification are classes
  • Test case derivation
    • By selecting one class from each classification, you can derive a test case

Steps of the classification tree method (Example)

We are to test a validate_date(date) function.

  1. Identifying the test object
  2. Decomposing it into features
  3. Identifying classifications (aspects) within each feature.
  4. Refining classifications if needed.
  5. Combining classifications systematically to generate test cases.

1. Identify the test object

Test object: a date

2. Decompose the test object into features

A date has:

  • Year
  • Month
  • Day

This can be be represented as:

date
├── year
├── month
└── day

3. Identify classifications within each feature

These are aspects or categories that might impact behaviour.

Year classification

year
├── ordinary
│   ├── negative (e.g., -50)
│   └── nominal (e.g., 2023)
└── leap year
    ├── ordinary (e.g., 2004)
    └── century (e.g., 2000 is leap; 1900 is not)

Month classification

month
├── February
├── 30-day months
│   └── April, June, September, November
└── 31-day months
    └── January, March, etc.

Day classification

day
├── start (1st)
├── middle (e.g., 15th)
├── end (last valid day of month)
└── invalid (> 31)

4. Refine classification if needed

You can further divide classes based on how detailed you want the tests. For example, leap years can be split into:

  • 4-divisible but not century years (e.g., 2004)
  • 400-divisible years (e.g., 2000)

Recursively apply these procedures as long as possible.

5. Combine classifications systematically to create test cases

Produce test cases by combining as many classifications as possible. For example, date composed of leap year, with 30 day months, and starting date.

def validate_date(date):
    ...
 
# Sample test case
mydate = "2004-04-01"  # Leap year, 30-day month, starting date
validate_date(mydate)

Example combinations

YearMonthDayExample DateWhy?
LeapApril1st2004-04-01Valid date; 30-day month, leap year
OrdinaryFebruary30th2023-02-30Invalid; Feb never has 30 days
CenturyFebruary29th2000-02-29Valid; leap century year
NegativeMarch15th-50-03-15Invalid; negative year
LeapFebruary29th2004-02-29Valid; leap day
OrdinaryApril31st2023-04-31Invalid; April has only 30 days

This process ensures systematic coverage and helps identify corner cases.

Example 2

Consider a login object, which is created when a user enters the username and password, which are then together considered for validation. This is how we build the tree

Login Attempt (user/pwd)
├── Username
│   ├── Valid
│   ├── Non-existent
│   ├── Empty
│   ├── Too long
│   └── Special characters
│
└── Password
    ├── Correct
    ├── Incorrect
    ├── Empty
    ├── Too short
    ├── Too long
    └── Special characters
TCUsernamePasswordExpected Result
1ValidCorrect✅ Login successful
2ValidIncorrect❌ Login failed
3ValidEmpty❌ Login failed
4ValidToo short❌ Login failed
5ValidToo long❌ Login failed
6ValidSpecial characters❌ Login failed (if disallowed)
7Non-existentAny❌ Login failed
8EmptyAny❌ Login failed
9Too longAny❌ Login failed
10Special charactersCorrect❌ Login failed (if username invalid)
11Special charactersSpecial characters❌ Login failed
12Non-existentCorrect❌ Login failed
13EmptyEmpty❌ Login failed
14Too longToo long❌ Login failed

Summary

  • Systematic classification avoids random gaps in testing
  • Recursive decomposition ensures all features are considered
  • Combining features leads to well-defined test cases with clear coverage

Back to parent page: Software Testing

Web_and_App_Development Software_Testing Blackbox_Testing SOFT3202 Classification_Tree