B卷
B卷
B卷
/卷号:B
1811561132 Total
Result
Teaching System Account
Shabid Shariare
Hassan
Grade & Class Reviewer
密
19 lq
Notice
IV. If the paper is not clear please ask the teacher for a new one.
III. Student shall write TSA, ID, Grade & Class in corresponding blank
II. TSA, ID can not be altered
I. Do not answer on the left part of the Sealing Line
Software Engineering
试题/Test Paper
封
(For 19lc 计科 1,19lq 软工 1,18lq 计科 1,20lc 软工 1) Opend Book
Q
I II III IV V VI VII VIII IX X
No.
Q
14 14 14 14 14 15 15
Result
Your
Result
Notice: Student ID, TSA and Grade & Class are not filled properly, the paper is invalid.
注意:学号、姓名和所在年级班级不写、不写全或写在密封线外者,试卷
作废。
1 / 12
Here is a class diagram that represents the relationship among the classes
"Person", "Mouth", "Foot", and "Student":
In this diagram, "Person" is the superclass and "Mouth", "Foot", and "Student" are
subclasses. "Mouth" and "Foot" are related to "Person" through composition, as
they are parts of a person's body. "Student" is related to "Person" through
inheritance, as a student is a type of person with additional attributes and behaviors
specific to being a student. All classes have methods specific to their functionality,
such as "eat()" and "talk()" for "Person", "open()" and "close()" for "Mouth", "lift()"
and "move()" for "Foot", and "study()" for both "Person" and "Student".
Ans:
The relationships between use cases and actors can be described as follows:
- Actors are the users or entities that interact with the system in some way. They
can initiate use cases by requesting the system to perform certain tasks or providing
input data. Actors can also receive output from the system or be affected by system
behavior. Actors are external to the system and can represent humans, other
software systems, devices, or organizations.
- Use cases are descriptions of the system's behavior and functionality from the
perspective of actors. Use cases define the goals, steps, and outcomes of the
interactions between actors and the system. Use cases capture the user requirements
and provide a basis for designing the system's features and functions. Use cases are
represented in diagrams as ovals or ellipses with descriptive names.
Here is a possible use case diagram that illustrate the releationship between the
actrors and use cases:
3 / 12
Result III There is a program to determine whether the sum of
Reviewer two integer variables is 0 or not 0. These two positive
integers are: a and b. Their value ranges are as follows:
-50<= a <=50
-50<= b <=50
Please use “Boundary Value Analysis Testing” method to design test data for this
program. (14 points)
Ans:
Boundary value analysis is a testing technique that uses boundary values of inputs
to design test cases. In this case, we have two integer inputs (a and b) that have a
range of -50 to 50. We need to design test cases using the boundary values of the
inputs. Here are the test cases we can design:
1. Test Case 1: a = -50, b = -50 - Test with the smallest possible values for both a
and b.
2. Test Case 2: a = -50, b = -1 - Test with the smallest value of a and a non-zero
value of b.
3. Test Case 3: a = -50, b = 0 - Test with the smallest value of a and the value of b
that is on the boundary line.
4 / 12
4. Test Case 4: a = -50, b = 1 - Test with the smallest value of a and a non-zero
value of b.
5. Test Case 5: a = -50, b = 50 - Test with the smallest possible value for a and the
largest possible value for b.
6. Test Case 6: a = -1, b = -50 - Test with a non-zero value of a and the smallest
possible value for b.
8. Test Case 8: a = -1, b = 1 - Test with a non-zero value of a and a non-zero value
of b.
9. Test Case 9: a = -1, b = 50 - Test with a non-zero value of a and the largest
possible value for b.
10. Test Case 10: a = 0, b = -50 - Test with 0 for a and the smallest possible value
for b.
12. Test Case 12: a = 0, b = 50 - Test with 0 for a and the largest possible value for
b.
13. Test Case 13: a = 1, b = -50 - Test with a non-zero value of a and the smallest
possible value for b.
14. Test Case 14: a = 1, b = 0 - Test with a non-zero value of a and 0 for b.
15. Test Case 15: a = 1, b = 1 - Test with a non-zero value of a and a non-zero value
of b.
16. Test Case 16: a = 1, b = 50 - Test with a non-zero value of a and the largest
possible value for b.
5 / 12
17. Test Case 17: a = 50, b = -50 - Test with the largest possible value for a and the
smallest possible value for b.
18. Test Case 18: a = 50, b = -1 - Test with the largest possible value for a and a
non-zero value of b.
19. Test Case 19: a = 50, b = 0 - Test with the largest possible value for a and the
value of b that is on the boundary line.
20. Test Case 20: a = 50, b = 1 - Test with the largest possible value for a and a
non-zero value of b.
21. Test Case 21: a = 50, b = 50 - Test with the largest possible values for both a
and b.
Result
Reviewer
IV. The following is a flow chart of the program. This program contains one
integer variables:x. And there are 5 steps in this program . Please answer the
following questions according to the following figure. (14 points)
6 / 12
(1) Please write out all paths where the program executes. The path is
represented by a step label, for example”Step1-Step2- .”
Ans:
1. Step1-Step2 (Yes)-Step3-Step5/Exit
2. Step1-Step2 (Yes)-Step4-Step5/Exit
3. Step1-Step2 (No)-Step5/Exit
Note that in this case, there is a Step5 which is reached after executing either Step3
or Step4, depending on the path taken at Step2
7 / 12
(2)Please use “Statement coverage” method to design test data for this program.
Ans:
To design test data using the "Statement coverage" method, we need to ensure that
each statement in the program is executed at least once. In this program, there are
five statements:
• Statement 1: x = x + 1
• Statement 2: x > 0 ?
• Statement 3: x = x* x
• Statement 4: x = x* x* x
• Statement 5: Exit
To cover each statement at least once, we can design the following test cases:
In test case 1, statement 1 is executed once and statement 5 is executed once. In test
case 2, statement 1 is executed once, statement 2 is executed once, and statement 5
is executed once. In test case 3, statement 1 is executed once, statement 2 is
executed twice (once in Step2 and once in Step3), statement 3 is executed once, and
statement 5 is executed once. In test case 4, statement 1 is executed once, statement
2 is executed twice (once in Step2 and once in Step4), statement 4 is executed once,
and statement 5 is executed once. In test case 5, statement 1 is executed once,
8 / 12
statement 2 is executed twice (once in Step2 and once in Step4), statement 4 is
executed twice, and statement 5 is executed once.
These test cases provide complete coverage of all the statements in the program.
Ans:
9 / 12
Here is the activity Diagram
As we can see, the process starts with the customer placing an order online. The
system then checks the inventory to see if the goods are available locally. If they
are, the website ships the goods directly to the customer. If the goods are not
available locally, the system transfers them from other places and then ships them
to the customer.
10 / 12
Result VI. The following is a flow chart of the program. This
Reviewer program contains one integer variables:x,y. Please use
“Judgment coverage” method to design test data for this
program. (15 points)
Ans:
use the judgment coverage method to design test data for this program.
1. Entry condition: x > 0 and y > 0
Test case 1: x = 1, y = 2 Test case 2: x = 2, y = 1 Test case 3: x = 3, y = 3
2. True branch (x > y):
Test case 4: x = 5, y = 2 Test case 5: x = 10, y = 9
3. False branch (x <= y):
Test case 6: x = 2, y = 5 Test case 7: x = 8, y = 8
4. Exit condition: after the if-else block, there is no further processing, so no
additional test cases are required.
Overall, these 7 test cases should provide adequate coverage for the program,
ensuring that both the true and false branches of the if-else statement are tested.
Additionally, we have tested the entry condition to ensure that the inputs are valid
(x > 0 and y > 0).
11 / 12
Result VII. There are two float inputs C and D for a
Reviewer multiplication function. Here are the ranges of the two
integer inputs:
1≤C≤2
-1 ≤ D ≤ 1
Use “equivalence class testing ”method to design test data for this function. (15
points)
Ans:
Equivalence class testing is a technique where inputs are divided into classes based
on their characteristics, and then test cases are created for each class. The goal is to
reduce the number of test cases while still ensuring that all possible scenarios are
covered.
For this multiplication function with two float inputs C and D, we can identify
different equivalence classes based on the ranges of the integer inputs:
Using these equivalence classes, we can come up with the following test cases:
These nine test cases cover all possible scenarios for the multiplication function
with the given input ranges.
12 / 12