3137102334_ Chao Wenxiang (experiment 4)

Source: Internet
Author: User

The experiment of software testing

Experiment Four white Box test

Experimental purpose

(1) Skills to master static analysis code

(2) Equivalence class division in the study of black box testing

Experimental content

First, find out the problems in the function. The following topics are completed in the Lab04 project.

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.

For:

Question 1: The first topic said that a site through user input user name and password to determine what kind of interface, but in the testing process, we just enter the account Admin or administrator in the Web interface can jump to the Administrator page, This is a serious problem: All users can log on to manage the page, there are security risks.

Issue 2: The arguments passed in May be null (in parentheses username and admin/administrator swap positions )

Solve:

public string Getuserrole (string username, string password) {

String userrole= "Guest";

IF (null! = password &&! "". Equals (password)) {

IF (Null! = Username &&! "". Equals (username)) {

if (admin.equals (userName) | | Administrator.equals (userName) {

userrole= "admin";

}

return userrole;

}

else{

return userrole;

}

}

else{

return userrole;

}

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.

For:

Problem: The user does not have a judgment type and does not know if there is an input value

Solve:

public boolean validateuserage (String userage) {

IF (null! = Userage &&! "". Equals (Userage)) {if (Integer.parseint (userage) >=18&&integer.parseint (userage) <=26) {

return true;

}

else{

return false;

}

}

else{

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 triangles are formed as side lengths of the three sides (the case of a special triangle is not considered). According to the instructions given, divide by equivalence class partitioning, and give each equivalence class A unique number.

The required judgment

Effective

Invalid

Three-bit non- 0 positive integer ABC

Do not enter 0

Input 0

Input

Blank

Lose 3 bits

A few or more people missing.

Enter a positive integer

Enter a different string

form a triangle

The number entered does not constitute a triangle

Instance

Required judgment

valid

Invalid

Three-bit non- positive integer abc

 

3    4   5  

 

 0   4     0 

 

3    4

A    b    5

1    1     1

3137102334_ Chao Wenxiang (experiment 4)

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.