Software Assurance and Testing Exercises

Software Assurance and Testing Exercises

Black box testing

1. A certain information encryption code consists of three parts, the names and contents of these three parts are

Encryption type code: blank or three digits;

Prefix code: three digits that do not start with '0' or '1';

Suffix code: four digits.

Assuming that the tested program can accept all information encryption codes that meet the above requirements, reject all information encryption codes that do not meet the requirements, try the equivalence class division method, analyze all its equivalence classes, and design test cases.

Equivalence class:

Partition set:

enterresultEquivalence class

2. The login interface of a "bank website system" is shown in the figure below. Try to use the error speculation method, cite 10 common problems or errors, and design 10 test cases.

3. There is an online shopping website system, the main functions include login, product purchase, online payment to complete shopping, etc. When users use these functions, various situations may occur, such as the account does not exist, the password is incorrect, and the account balance is insufficient. Suppose that there is only one account abc in the system; the password is 123; the account balance is 200; there is only product A, the price is 50 yuan, the inventory is 15, the product B sells for 50 yuan, and the inventory is 0.

Try to use the scenario method: analyze and draw the event flow diagram, mark out the basic flow and alternative flow; analyze and generate test scenarios.

Basic flow: log in to the website--->buy goods--->online payment

Alternative flow 1: The account does not exist

Alternative flow 2: Incorrect password

Alternate flow 3: Out of stock

Alternative flow 4: insufficient account balance

Scenario 1: Successfully log in and complete the shopping operation

Scenario 2: The account does not exist

Scenario 3: Incorrect password

Scenario 4: Out of stock

Scenario 5: Insufficient account balance

Test case IDScenesaccount numberpasswordoperatingexpected outcome
1Scenario 1: Successfully log in and complete the shopping operationAdmin123456Shop A goodspayment successful
2Scenario 2: The account does not existTest123465n/aLogin failed
3Scenario 3: Incorrect passwordAdmin888888n/aLogin failed
4Scenario 4: Out of stockAdmin123456Shop B goodsPayment failed
5Scenario 5: Insufficient account balanceAdmin123456Shop A and B productsPayment failed

4. There is a "user information input" interface as shown in the figure below. There are 3 input items: name, nickname, mobile phone number, and there are two states: filled and not filled. Please use the orthogonal experiment method to test it.

(1) Orthogonal table

Serial numberNamenicknamenumber

(2) Mapping results and test cases

Serial numberNamenicknamenumberresult
1Don't fill inDon't fill inDon't fill infailure
2Don't fill inDon't fill infillfailure
3Don't fill infillDon't fill infailure
4Don't fill infillfillfailure
5fillDon't fill inDon't fill infailure
6fillDon't fill infillfailure
7fillfillDon't fill infailure

5. There is a beverage vending machine software with a unit price of 5 cents. Its specifications are as follows: if you put in a coin of 5 cents or 1 yuan, press the button of [Orange Juice] or [Beer], the corresponding drink will be Send it out. If there is no change in the vending machine, a red light showing Change is complete is on. At this time, after inserting a 1 yuan coin and pressing the button, the drink will not be delivered and the 1 yuan coin will also be withdrawn; if there is change, then The red light indicating [finished change] is off, and the 5 dime coin will be refunded when the drink is delivered.

(1) Analyze the software specifications and list the reasons and results.

(2) Draw a cause and effect diagram.

(3) List the simplified judgment table

(1) Cause and result table

(2) Cause and effect diagram

(3) Judgment table

6. The function of a program is to output tomorrow's date of a certain input date. For example , if you input February 2, 2020, the output of the program will be February 3, 2020. The program has three input variables year, month, and day, which respectively represent the year, month, and day of the input date.

(1) Please divide the input variables year, month, and day into effective equivalence classes according to the program specifications.

(2) Analyze the specification of the program, and combine the above equivalence class division to give all possible operations for the program.

(3) According to (1) and (2), draw a simplified decision table, and design test cases for each rule.

(1) Effective equivalence class

(2) Possible operations

(3) Decision table

White box testing

1. Please design a set of test cases for the following program segments, which are required to meet statement coverage, judgment coverage, condition coverage, condition/judgment coverage, and condition combination coverage.

public int do_work ( int A, int B) { int x = 0 ; if ((A> 4 ) && (B< 9 )) {x = AB;} if (A== 5 && B> 28 ) {x = A+B;} return x; } Copy code

Statement coverage:


Judgment coverage:


Condition coverage:


Condition/judgment coverage:


2. Please design a set of test cases for the following program segments, which are required to meet the conditional combination coverage

public class Triangle { protected long lborderA = 0 ; protected long lborderB = 0 ; protected long lborderC = 0 ; //Constructor public Triangle ( long lborderA, long lborderB, long lborderC) { this .lborderA = lborderA; this .lborderB = lborderB; this .lborderC = lborderC; } public boolean isTriangle (Triangle triangle) { boolean isTriangle = false ; //check boundary if (triangle.lborderA> 0 && triangle.lborderB> 0 && triangle.lborderC> 0 ) //check if subtraction of two border larger than the third if ((triangle.lborderA-triangle.lborderB) <triangle. lborderC && (triangle.lborderB-triangle.lborderC) <triangle.lborderA && (triangle.lborderC-triangle.lborderA) <triangle.lborderB) {isTriangle = true ;} return isTriangle; } } Copy code

3. Please be the program module Function1

(1) Draw the program control flow diagram and calculate the loop complexity of the control flow diagram

(2) Export the basic path

(3) Design basic path coverage test cases

The code of the program module Function1 is as follows:

1 public int Function1 ( int num, int cycle, boolean flag) 2 { 3 int ret = 0 ; 4 while (cycle> 0 ) 5 { 6 if (flag == true ) 7 { 8 ret = num- 10 ; 9 break ; 10 } 11 else 12 { 13 IF (NUM% 2 == 0 ) 14 { 15 RET RET * = 10 ; 16 } . 17 the else 18 is { . 19 RET RET = + . 1 ; 20 is } 21 is } 22 is cycle--; 23 is } 24 return RET; 25 } copy the code

4. Please mutate the following code segment, the mutation rule is to replace "++" with "--", and then design the test data to be able to test and find all the mutation points.

public class zhengchu { public String iszhengchu ( int n) { if (n< 0 ||n> 500 ) { return "error" ; } int flag = 0 ; String note= "" ; if (n% 3 == 0 ) { flag++; note=note+ "3" ; } if (n% 5 == 0 ) { flag++; note+= "5" ; } if (n% 7 == 0 ) { flag++; note+= "7" ; } return "can be divisible by " +flag+ "number," +note; } } Copy code

Integration Testing

1. There are two pieces of code ModuleA and ModuleB as follows, they are developed by different programmers.

(1) Try to analyze what problems will arise when integrating these two pieces of code?

(2) Try to design two test data, one can find this problem, the other cannot find this problem.

public class ModuleA { /*** Realize the function of returning the content after removing str2 contained in str1 * @param str1 string 1 * @param str2 string 2 * @param returns the result of processing */ public String operate (String str1, String str2) { return str1.replace(str2, "" ); } } public class ModuleB { private ModuleA moduleA; public void setModuleA (ModuleA moduleA) { this .moduleA = moduleA; } /** * In the specific processing operation of module B, the interface of module A is called */ public String operate (String str1, String str2) { //str1 The target string to be replaced //str2 The original string return moduleA.operate(str1, str2); } } Copy code

(1) The goal of ModuleB is to replace (remove) the string containing str1 in str2, and the interface provided by ModuleA is to replace or delete the string containing str2 in str1. The two interfaces are reversed, and string replacement will be disorder problem


System test

1. A chain agency website has 50,000 registered accounts. On average, about 12,000 users want to access the system in a day. Users generally use the system from 7 to 22:00. In a day, the average number of users using the system is The duration is about 0.5 hour. Assuming that the user login to access the system conforms to the Poisson distribution, for concurrent testing, please estimate the average number of concurrent users C_avg and the peak number of concurrent users C_max of the system.

The average number of concurrent users of the system:


Peak number of concurrent users:


Software quality assurance

1. A software company designed and developed a ticketing system for a movie theater, including ticket management, account management, online ticket purchase, statistical analysis and other functions. The software is planned for long-term use, and some modules will be used in other similar software. The software is in use Should be able to access the digital city platform. Try to analyze which characteristics should be used to analyze and evaluate the quality of this software in combination with the software quality model analysis.