Software Validation and Quality Assurance: Sample Exam
Name (Please Print): ______
PART I MultipleChoiceI (6*8points = 48 points)
Only one answer can be the correct answer.
1. Which statement below is CORRECT about the reason why nowadays testing is the most popular way for bug removal?
A. Testing usually does not generate false positives as static checking does
B. Testing is cheaper than code review
C. Testing is able to guarantee the absence of certain types of bugs
D. With current techniques, testing can usually be done fully automatically
2. After running test, we need to compare the output with ____ to decide whether the test passes or fails?
A. Test Case
B. Test Suite
C. Test Oracle
D. Test Driver
3. For the input range x in [0, 99], and y in [-10, 10], how many test cases are required for boundary value testing, robustness testing, and worst-case testing, respectively?
A. 4, 8, 16
B. 9, 13, 25
C. 9, 17, 25
D. 4, 13, 49
4. For a string input, three features are extracted to build the equivalent classes: string_length= [0, 1, other]; contain_space = [true, false]; ends_with=[number, letter, other].Different combinations of features are considered as different equivalent classes. What is the number of equivalent classes that are coverable?
A.8
B. 11
C. 13
D. 18
5. Which of assertions below is best to be used in unit testing?
A. assertTrue(fFull.size() == 100+size);
B. assertEquals(fFull.size(), 100+size);
C. assertEquals(100+size, fFull.size());
D. assertEquals(“list length”, 100+size, fFull.size());
6. Consider the following input model and test cases, we want to add a test case to enhance the input combination coverage, which test case can enhance the 2-wise input combination coverage most?
Input Model:
Color = {red, green, blue}
Size = {large, small}
Style = {classic, modern}
Current Test Cases:
[red, small, modern]
[green, large, classic]
A. [red, large, modern]
B. [blue, small, modern]
C. [blue, large, modern]
D. [blue, large, classic]
PART II Short Answer Questions (26*2 = 52 points)
1. Consider the testing of a class Order. The class Order depends on another class Shop, which is not implemented yet.
Part of the class Order is defined as below:
public class Order{
public Order(Shop sp, String name, int amount){...}
public double getSum(){...} //s1: should call getDiscount() in Shop class, and it should return 0.8
public void save(){...} //s2: should call save(Order order) in Shop class
}
Please fill in the blanks in the following test method to test the methods "getSum", and "save" in class Order. In the test code, you should check whether s1 and s2 hold, with EasyMock Framework. (9 points).
Note:
(1) Assuming there is not setup method in the class
(2) Only pseudo code is required, minor syntax errors, missing imports, API signature errors do not matter, just show you know which type of code should be filled in.
(3) You may need to fill in multiple statements in each blank.
@Test
public void testOrder() {
//initialize
Shop sp = EasyMock.CreateMock(Shop.class);
…
//record
EasyMock.expect(…);
EasyMock.expect(…);
//replay
EasyMock.replay(sp);
…
EasyMock.verify(sp)
}
2. Please generate a test case that provide most branch coverage enhancement to the following program.
Program:
while (x < 100){
if (x<y){
print(“1”);
}
if(x<2*y){
print(“2”)
}
x = x + 1;
}