Home Basic SDP Test Case Web Testing FAQ Others
You are here: Home>>Basic Concept>> Equivalence Class

Introduction

Testing Types

Black Box Testing

GUI Test Checklist

Stubs and Drives

Decision tables

you are here Equivalence Class

Standards for software

Integration

Software Review

Usability Testing

Load / Stress Testing

QA Glossary


We need your help! To keep the site alive, please make the donation by clicking the button below.
Thank you very much!

How to Make a Donation Using PayPal Without an Account?

Test Cases and Scenarios - Equivalence Class

Equivalence Class

* Equivalence class testing is a technique used to reduce the number of test cases to a manageable level while still maintaining reasonable test coverage.
* This simple technique is used intuitively by almost all testers, even though they may not be aware of it as a formal test design method.
* Many testers have logically deduced its usefulness, while others have discovered it simply because of lack of time to test more thoroughly.

Equivalence Class

* Consider this situation. We are writing a module for a human resources system that decides how we should process employment applications based on a person's age. Our organization's rules are:
Equivalence Class of Hire
* 0-16 Don't hire
* 16-18 Can hire on a part-time basis only
* 18-55 Can hire as a full-time employee
* 55-99 Don't hire[*]

Equivalence Class of Hire

* Should we test the module for the following ages: 0, 1, 2, 3, 4, 5, 6, 7, 8, ..., 90, 91, 92, 93, 94, 95, 96, 97, 98, 99?
* If we had lots of time ?
Develop coding
* If (applicantAge == 0) hireStatus="NO";
* If (applicantAge == 1) hireStatus="NO";
* ...
* If (applicantAge == 14) hireStatus="NO";
* If (applicantAge == 15) hireStatus="NO";
* If (applicantAge == 16) hireStatus="PART";
* If (applicantAge == 17) hireStatus="PART";
Develop coding
* If (applicantAge == 18) hireStatus="FULL";
* If (applicantAge == 19) hireStatus="FULL";
* ...
* If (applicantAge == 53) hireStatus="FULL";
* If (applicantAge == 54) hireStatus="FULL";
* If (applicantAge == 55) hireStatus="NO";
* If (applicantAge == 56) hireStatus="NO";
* ...
* If (applicantAge == 98) hireStatus="NO";
* If (applicantAge == 99) hireStatus="NO";
Develop coding
* Luckily, programmers don't write code like this (at least not very often). A better programmer might write:
Develop coding
If (applicantAge >= 0 && applicantAge <=16)
hireStatus="NO";
If (applicantAge >= 16 && applicantAge <=18)
hireStatus="PART";
If (applicantAge >= 18 && applicantAge <=55)
hireStatus="FULL";
If (applicantAge >= 55 && applicantAge <=99)
hireStatus="NO";

Equivalence Class

* Given this typical implementation, it is clear that for the first requirement we don't have to test 0, 1, 2, ... 14, 15, and 16.
* Only one value needs to be tested.
* And which value? Any one within that range is just as good as any other one.
* The same is true for each of the other ranges.
* Ranges such as the ones described here are called equivalence classes.

Equivalence Class

We will expect:
* If one test case in an equivalence class detects a defect, all other test cases in the same equivalence class are likely to detect the same defect.
* If one test case in an equivalence class does not detect a defect, no other test cases in the same equivalence class is likely to detect the defect.

Equivalence Class

A group of tests forms an equivalence class if you believe that:
* They all test the same thing.
* If one test catches a bug, the others probably will too.
* If one test doesn't catch a bug, the others probably won't either

Continuous equivalence classes

Discrete equivalence classes

Single selection equivalence classes
* GMC will make mortgages only for a person. They will not make mortgages for corporations, trusts, partnerships, or any other type of legal entity.
Multiple selection equivalence class
* GMC will make mortgages on Condominiums, Townhouses, and Single Family dwellings. They will not make mortgages on Duplexes, Mobile Homes, Treehouses, or any other type of dwelling

Identifying Equivalence Class

* If an input condition specifies a continuous range of values, select one valid class and two invalid classes
* If an input condition specifies a discrete range of permissible values, select one valid class and two invalid classes
Identifying Equivalence Class
* If an input condition enumerates a set of values, identify one valid equivalence class and one invalid equivalence class
* If a 搈ust be?condition is required, identify one valid equivalence class and one invalid equivalence class

Reference

* A Practitioner's Guide to Software Test Design
by Lee Copeland ISBN:158053791X
Artech House ?2004
* Beizer, Boris (1990). Software Testing Techniques (Second Edition). Van Nostrand Reinhold.
* Binder, Robert V. (2000). Testing Object-Oriented Systems: Models, Patterns, and Tools. Addison-Wesley.
 

Choosing Test Data

In system testing, test data should cover the possible values of each parameter based on the the requirements. Since testing every value is impractical, a few values should be chosen from each equivalence class. An equivalence class is a set of values that should all be treated the same.

Ideally, test cases that check error conditions are written separately from the functional test cases and should have steps to verify the error messages and logs. Realistically, if error test cases are not yet written, it is OK for testers to check for error conditions when performing normal functional test cases. It should be clear which test data, if any, is expected to trigger errors.

Example equivalence classes:

Strings
  • empty string
  • String consisting solely of white space
  • String with leading or trailing white space
  • syntactically legal: short and long values
  • syntactically legal: semantically legal and illegal values
  • syntactically illegal value: illegal characters or combinations
  • Make sure to test special characters such as #, ", ', &, and <
  • Make sure to test "Foreign" characters typed on international keyboards
Numbers
  • empty string, if possible
  • 0
  • in range positive, small and large
  • in range negative, small and large
  • out of range positive
  • out of range negative
  • with leading zeros
  • syntactically invalid (e.g., includes letters)
Identifiers
  • empty string
  • syntactically legal value
  • syntactically legal: reference to existing ID, invalid reference
  • syntactically illegal value
Radio buttons
  • one item checked
  • nothing checked, if possible
Checkboxes
  • checked
  • unchecked
Drop down menus
  • select each item in turn
Scrolling Lists
  • select no item, if possible
  • select each item in turn
  • select combinations of items, if possible
  • select all items, if possible
File upload
  • blank
  • 0 byte file
  • long file
  • short file name
  • long file name
  • syntactically illegal file name, if possible (e.g., "File With Spaces.tar.gz")