1. Topic Requirements
2. Implementation methods
I used the Html+servlet method. HTML gives the front-end userform1,servlet processing input in the background and returns the result of the judgment.
Here is the structure of the project and the look of the front end (important code is affixed at the end)
3. Classification of equivalence classes, test cases and experimental results
Invalid equivalence class for valid equivalence class
Length 1~6 input is empty
Character: a~z,a~z,0~9 input length greater than 6
Contains special characters
From the top, the test case is: 1.ab53c
2. Null input
3.1234avbs
4.%250a
5. Little Brother Bai
Test process and test results such as:
1.ab53c
2. Null input
3.1234avbs
4.%250a
5. Little Brother Bai
4. Results analysis
equivalence class, effective equivalence class, invalid equivalence class can make the testing process simple and effective, and should be used in the test process in the future.
5. Key code
PrintWriter out =Response.getwriter (); String name= Request.getparameter ("username"); if(Name.length () > 6) {out.println ("<! DOCTYPE HTML public \ "-//W3C//DTD HTML 4.01 transitional//en\" > "); Out.println ("); Out.println ("); Out.println ("<title> Invalid </title>"); Out.println ("); Out.println ("<body>"); Out.println ("); Out.println ("</body>"); Out.println ("); Out.flush (); }Else{ BooleanOK =true; for(inti = 0;i < Name.length (); i++){ if(Character.getnumericvalue (Name.charat (i)) < 0) {//Determine if the input is Chinese OK=false; Break; } if(!Character.isletterordigit (Name.charat (i))) {OK=false; Break; } }if(OK) {out.println ("<! DOCTYPE HTML public \ "-//W3C//DTD HTML 4.01 transitional//en\" > "); Out.println ("); Out.println ("); Out.println ("<title> Effective </title>"); Out.println ("); Out.println ("<body>"); Out.println ("); Out.println ("</body>"); Out.println ("); Out.flush (); }Else{out.println ("<! DOCTYPE HTML public \ "-//W3C//DTD HTML 4.01 transitional//en\" > "); Out.println ("); Out.println ("); Out.println ("<title> Invalid </title>"); Out.println ("); Out.println ("<body>"); Out.println ("); Out.println ("</body>"); Out.println ("); Out.flush (); } }
6. Write in the back
Because C1,C2 can not occur simultaneously, there are 24 kinds of cases to consider, when c1,c2 are 0 o'clock, cause and effect
Diagram logic is OK, C1,C2 has a unique when pressing a drink button no problem, press 2 or 3
A button line I think see how the program is written, if the logic of the program is to press Coke, Sprite, black tea
In order to determine whether the button is clicked, the other is or the relationship, so the beverage machine just give a judgment to
First kind of drink.
Test cases for software testing------USERFORM1