Equivalence Division of Test Cases

Source: Internet
Author: User

Premise

How does the program enter test data to be the most comprehensive test? Enter all possibilities and use the exhaustive method for testing. But think about it and know that the exhaustive test is a low-cost and impossible test. So, what we can do is to design the fewest test cases to do the most comprehensive testing .

One method commonly used in test cases, equivalence class partitioning, is to solve the problem of how to select the appropriate subset of data to represent the whole data set, by reducing the number of tests to achieve "reasonable" coverage, covering more potential data sink. Here is a detailed introduction to you.


First, the theorydefinition

is to divide all possible input data , that is, the input fields of the program into sections (subsets), and then select a small number of representative data from each subset as test cases.

The equivalence class is divided into valid equivalence class and invalid equivalence class.

1) Effective equivalence class

Refers to a set of input data that is reasonable and meaningful for the specification of a program. The effective equivalence class can be used to verify whether the program implements the functions and performance specified in the specification.

2) Invalid equivalence class

Refers to the specification of the program is unreasonable or meaningless input data constitute a collection. For a specific problem, the invalid equivalence class should have at least one or more.

Standard

1) Complete testing, avoid redundancy

2) It is important to classify equivalence classes by dividing the set into subsets of disjoint groups, which are the entire set

3) and is the entire set: Ready

4) subset disjoint: guarantees a form of non-redundancy

5) A test case is identified (selected) in the same class, the same equivalence class is often processed the same, and the same processing is mapped to the "Same execution path".

Method

1) In cases where the input condition specifies the range of values or the number of values , you can establish a valid equivalence class and two invalid equivalence classes. such as: The input value is the student achievement, the scope is 0~100;

2) A set of input values is specified in the input conditions, or a valid equivalence class and an invalid equivalence class can be established in the case of "what must be" condition;

3) In the case where the input condition is a Boolean quantity , a valid equivalence class and an invalid equivalence class can be determined.

4) A set of values that specify the input data (assuming N), and if the program is to handle each input value separately, it can establish n valid equivalence class and an invalid equivalence class.

Example: Enter a condition to explain the degree : Four kinds of college, undergraduate, master, PhD, respectively, take these four kinds of these four values as four effective equivalence class, in addition to four kinds of qualifications other than any academic qualifications as invalid equivalence class.

5) In the case of rules that require the input data to be complied with , a valid equivalence class (conforming to a rule) and several invalid equivalence classes (which violate the rules from different angles) can be established;

6) In cases where the elements in the program are handled differently in the known equivalence class , the equivalence class should be further divided into smaller equivalence classes.

Design Process

After the equivalence class is established , an equivalence class table is established, which lists all the equivalence class input conditions: Valid equivalence class, invalid equivalence class, and then designs the test case from the divided equivalence class according to the following three principles:

1) Specify a unique number for each equivalence class;

2) Design a new test case so that it overwrites as much of the valid equivalence class as it has not yet been overwritten, repeating this step until all valid equivalence classes are overwritten;

3) Design a new test case so that it overwrites only one invalid equivalence class that has not yet been overwritten, repeating this step until all invalid equivalence classes are overwritten.

external conditions                   

valid equivalence class

invalid equivalence class

Second, practiceClassic Triangles:

title: "Enter three integers A, B and C are triangular as the sides of the three sides respectively. The type of triangle formed by the program is determined, and when the triangle is a general triangle, isosceles triangle and equilateral triangle, the calculation is made separately ... "

Analysis:

The conditions of the triangle, three numbers can not be zero, the sum of the two sides is greater than the third side; isosceles triangle, two sides are equal; equilateral triangle, three sides are equal; Programs generally enter four cases of "non-triangular", "General Triangle", "isosceles triangle", "equilateral triangle".

Then enter the requirements for the condition:

( 1) Integer (2) three digits (3) non-zero (4) positive number

( 5) The sum of the two sides is greater than the third side (6) isosceles (7) Equilateral

Next, we'll design the test cases:

external conditions          

Valid equivalence classes

Invalid equivalence class (coarse granularity)

Enter a three integer

integer

three number

non zero

positive

not integer

No three numbers

at least one is zero

not positive

General triangle

a+b>c

The sum of the two sides is less than or equal to the third side

isosceles triangle

a=b Span lang= "ZH-CN" >≠ c

No two sides are equal

Equilateral triangle

A=b=c

Three sides are not equal

Iii. concluding remarks

This example is for reference only. Theoretical methods learned, but also in the actual application of the project, consider a comprehensive, deep thinking, design high-quality code!


Equivalence Division of Test Cases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.