322 235 Software Testing

advertisement
322 235 Software Testing
Laboratory# 7
Whitebox testing
Question#1
1. Please create a Test Script file using Junit to
examine defects of program Commission.java. We
assume that Programmer developed the program
and please answer question at the end of
question#1.
Commission.java
1.
2.
public class Commission {
public static double Calculate(int lock, int
stock, int barrel) {
3.
double sale =
(45*lock)+(30*stock)+(25*barrel);
4.
5.
if(sale<=1000)
return (sale*0.1);
By Dr.Wararat Songpan(Rungworawut)
หน้า 1
322 235 Software Testing
else if (sale > 1000)
6.
return (0.15*(sale-1000))+1000;
7.
else if (sale > 1800)
8.
return (0.2*(sale-1800))+220;
9.
else
10.
return 0.0;
11.
}
12.
13.
public static void main(String[] args) {
14.
System.out.print("Program Commision");
15.
}
16.
}
Specification of Commission.java as follows,
- Input
The number of Locks is [1,70]
The number of Stocks [1, 80]
The number of barrels [1,90]
- Condition and output
The commission is calculated from
Sale = 45*Locks + 30*Stock + 25*barrels
By Dr.Wararat Songpan(Rungworawut)
หน้า 2
322 235 Software Testing
If sale < 1000
Commission = 10% * sale
If sale >= 1000
Commission = 10%*1000 + 15%*(sale – 1000)
if sale > 1800
Commission = 10%*1000+ 15%*800+ 20%* (ราคาขาย1800)
2. Please create CommisionTest.java by tester, who designed
Test Case table from this table as below,
Test
Locks
Stocks
Barrels
Sales
Commission
OWN1
5
5
5
500
50
OWN2
15
15
15
1500
175
OWN3
12
25
25
2500
360
Case
ID
By Dr.Wararat Songpan(Rungworawut)
หน้า 3
322 235 Software Testing
Please answer the question is
Which Test case from test script file that are created following
the test case table to be fail. And Tester consults with
programmer, the program should be revised or not.
Question#2
1. Please
swap
between
programmer
and
tester
responsibility. Programmer creates a new java class as
Triangle.java following the pseudo code. As tester is ready
to create TriangleTest.java following the test case table as
below,
2. Tester and programmer check the test cases is coverage
how many percentage by EclEmma tool. Must create test
cases coverage the program at least 90%.
By Dr.Wararat Songpan(Rungworawut)
หน้า 4
322 235 Software Testing
Table of Test case design by Path Testing.
Test Case
a
b
c
Expected Output
Path
1
3
4
5
Scalene
P1
2
4
1
2
Not a Triangle
P6
3
5
5
5
Equilateral
P4
4
3
2
2
Isosceles
P5
By Dr.Wararat Songpan(Rungworawut)
หน้า 5
Download