Thinking of equivalence class division

Source: Internet
Author: User
Tags how to write test cases

First, the meaning of Equivalence class division

Partitioning means dividing a complete set into multiple sets.

The equivalence class means that the element division in the same equivalence class is equivalent to the same person.

Then dividing the complete set into multiple equivalence classes each equivalence class takes a use case to cover all cases to achieve the most comprehensive test range, and the minimum number of tests.

Second, how to divide the equivalence class

There are many kinds of situations, mainly look at their own classification criteria. Note that there is no intersection between equivalence classes, and each equivalence class is combined

1. Numerical class: Middle of interval, two parts outside the interval

2. Nature: By number (odd even), whether it is a letter, etc.

As long as the valid equivalence class and the invalid equivalence class can be separated.

Third, how to write test cases by equivalence class

The goal is to override all equivalence classes

When you write a test case, there is a test case that overrides multiple equivalence classes, and it is important to note that all of the last covers are covered, and a duplicate overwrite is not a relationship

Cases:

Only numbers and letters can be entered in the input box, and the length must be between 1-6

Valid equivalence classes:

1. Length 1-6

2. Enter letters or numbers

Invalid equivalence class

1. length 0, greater than 6

2. Enter characters other than alpha-numeric

Number Test Cases Expected output
1 Ok That's right
2 111 That's right
3 Ok..

Please enter a letter or a number

4 111..

Please enter a letter or a number

5 1234567

Please enter a character length of 1 to 6

6 1234567.. Please enter a letter or a number

Key OBJECTIVE-C Code

-(ibaction) OK: (ID) Sender {

    nsstring * input = _input. Text

    uialertview * alert = [[uialertview alloc ]initwithtitle:nil message :nil delegate: self cancelbuttontitle:@ " OK " otherbuttontitles: nil

nsstring* rangestr = @ "^ ([a-z0-9a-z]) *$";

nsrange range1 = [input rangeofstring: rangestr options:nsregularexpressionsearch ];

if (range1. Location = = Nsnotfound) {

Alert. message = @ " Please enter a letter or number ";

[Alert show];

}

Else if (input. Length>6 | | input. Length= =0) {

Alert. message = @ " Please enter a character length of 1 to 6";

[Alert show];

}

else{

Alert. message = @ " entered correctly ";

[Alert show];

}

}

Test result diagram

Thinking of equivalence class division

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.