First, find out the problems in the function.
1, a site through the user input user name and password (entered in the login.jsp login page) to determine what kind of interface, if the administrator (that is, the user named Admin or administrator) jump to the Administrator page (welcome_admin.jsp), Non-administrative users jump to the normal user interface (welcome.jsp). Visitors visit the site, without entering the user name and password, directly into the normal user interface (welcome.jsp).
Requirements : Identify the problem with the Getuserrole () method in the Useroperation.java file, explain the cause of the problem, and modify it.
Description: Not required to write JUnit unit test cases, you can imagine the test data, through static analysis, with dynamic debugging to find the problem.
Problem: Just enter admin to go to admin page
Cause: no password check
Modify:
Java:
public string Getuserrole (string username,string userpassword) {string userrole= "guest"; if (username.equals ("admin") | | Username.equals ("Administrator")) {userrole= "admin";} if (!userpassword.equals ("123456")) { userrole = "Guest";} return userrole;}
Jsp:
<%@ page language= "java" pageencoding= "GBK" import= "java.sql.*"%><jsp:usebean id= "Useropebean" scope= "page" class= "Com.fenglong.service.UserOperation" ></jsp:usebean>
2, user registration (register.jsp) to enter the age field, the user input parameters from the Useroperation.java file Validateuserage () method, converted to a numeric type, to determine whether the age between 18~26 (including 18 and 26), If the age is within this interval, then return true to jump to the login.jsp page, otherwise pop-up prompts that indicate "user age input is incorrect".
Requirements: Identify the problem with the Validateuserage () method in the Useroperation.java file, explain the cause of the problem, and modify it.
Description: Not required to write JUnit unit test cases, you can imagine the test data, through static analysis, with dynamic debugging to find the problem.
Problem: Error entering English characters
Cause: The type cannot be converted
Modify:
public boolean validateuserage (String userage) {int Age;try {age = Integer.parseint (Userage),} catch (Exception e) {age = 0 ;} if (age<18 | | age>26) {return true;} return false;}}
Second, the use of the equivalent class division in the black box test to complete the following topics
3, a procedure stipulates: "Input three non 0 positive integers a, B, c as the three sides of the side length of the triangle (the case of special triangles are not considered). According to the instructions given, divide by equivalence class partitioning, and give each equivalence class A unique number.
| Input criteria |
Valid equivalence classes |
Number |
Invalid equivalence class |
Number |
| triangles three sides |
positive |
1 |
side < 0 |
a < 0 |
11 |
| b < 0 |
12 |
| C < 0 |
13 |
| < 0 on both sides |
A < 0 and B < 0 |
14 |
| b < 0 and C < 0 |
15 |
| A < 0 and C < 0 |
16 |
| three sides < 0 |
a < 0 and B < 0 and C < 0 |
17 |
| Integer |
2 |
One side is a non-integer |
A is a non-integer |
21st |
| b is non-integer |
22 |
| C is a non-integer |
23 |
| Both sides are non-integers |
A, B is a non-integer |
24 |
| B, C is a non-integer |
25 |
| A, C is a non-integer |
26 |
| All three sides are non-integers |
A, B, and C are non-integers |
27 |
| Non-Zero |
3 |
One side is zero |
A = 0 |
31 |
| b = 0 |
32 |
| c = 0 |
33 |
| Zero on both sides |
A = 0 and b = 0 |
34 |
| b = 0 and c = 0 |
35 |
| A = 0 and c = 0 |
36 |
| Zero for all three sides |
A = 0 and B = 0 and c = 0 |
37 |
| Three x Sides |
4 |
Just give one side. |
Only for a |
41 |
| Only for a |
42 |
| Just give C |
43 |
| Just to both sides. |
Give only A, b |
44 |
| Just give B, C. |
45 |
| Give only A, C |
46 |
| Give more than three |
|
47 |
| The sum of the sides is greater than the third side |
5 |
The sum of the two sides equals the third side |
A + b = a |
51 |
| B + c = A |
52 |
| A + c = b |
53 |
| The sum of the two sides is less than the third side |
A + b < a |
54 |
| B + C < A |
55 |
| A + C < b |
56 |
"Software Test" experiment four: White box test