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