Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Quiz 1 - SENG 437 - Software Testing

Date/Time: March 01, 2016, 3:30 - 4:40 PM


Location: ST 128

Instructor: Yasaman Amannejad

Full Name

Solution

UCID

This booklet has 11 questions.


Please use the white pages at the end of this booklet, if you need additional space for your
answers.

Good luck!

<< This page has intentionally left blank >>

Question
1
2
3
4
5
6
7
8
9
10
11

Max grade
4
5
2
4
3
2
2
4
2
3
9

Your grade

Grade: /40

UCID

1. Define following terms (short answers): [4 Marks]


a. Failure: A failure occurs when a fault executes
Error: the very root cause. Errors are human mistakes.
Fault: A fault is the result and representation of a human error in the software documentation,
code, etc.
Incident: An incident is the symptom associated with a failure that alerts the user of the occurrence
of the failure. It is observed by the user.
b. Exhaustive Testing: Testing a system with all possible inputs
c. Test Smell: A set of symptoms of an underlying problem in test code.
d. Smoke Test: aims at ensuring that the BASIC and CRITICAL functions work. The results of
this testing is used to decide if a build is stable enough to proceed with further testing.
2. True/False [5 Marks]
a. We test software to show that system meets users needs.
b. We test software to find faults in software.
c. Alpha acceptance test is done by software testers and beta acceptance test
is done by a selected group of end users.
d. We test software to prove the correctness of application
e. Mutation testing tests the production code.

True
True
False
False
False

3. Multiple Choice Questions:


a. The most important thing about early test design is that it: [1 mark]
o makes test preparation easier
o means inspections are not required
o can prevent fault multiplication
o will find all faults
b. What statement about expected outcomes is FALSE: [1 mark]
o Expected outcomes are defined by the softwares behavior
o Expected outcomes are derived from a specification, not from the code
o Expected outcomes include outputs to a screen and changes to files and databases
o Expected outcomes should be predicted before a test is run
o Expected outcomes may include timing constraints such as response times
4. Name two advantages and two disadvantages of exploratory testing? [4 Marks]
+
Easy and fast to focus on critical areas
Fast reaction to changes
Ability to work with missing or weak
documentation
Low documentation overhead
Fast feedback
Utilizing the skills and experience of the
tester
PAGE 1

Planning and tracking is hard


Logging and reporting is not easy
Hard to calculate the coverage

UCID

5. Does software testing add costs to the software life cycle or reduce the costs? Explain your answer. [3
Marks]
In short term it adds cost due to cost of testing activities. However, it reduces the cost in long term due
to reducing the maintenance costs.

6. Using an example, discuss the difference between decision coverage and condition coverage. [2 Marks]
Decision coverage considers the true and false values for the predicate. Condition coverage considers
the true and false for every condition in the predicate. Example:
If ( a || b )
x=1
else
x=2
In decision coverage, the aim is to make ( a || b ) to be once True, and once false.
In condition coverage, cases where a= True, a = false, b = true, b = false must be tested.
7. How mutation testing works? Name two different types of mutation operators. [2 Marks]
Mutation testing works by making small changes in the system and re-running the tests. An effective
test suite must be able to identify the changes and kill the mutants. If mutants are survided, we need
to add more tests cases to improve the quality of our test suite.
Class level mutant operators: Access modifier change, Hiding variable deletion, etc.
Method level mutant operators: Constant replacement, Return statement replacement
8. Name two integration testing strategies? What are the advantages and disadvantages of each [4
Marks]
Incremental integration Bottom up
+ Visibility of detail
+Fault Localization
- Tests the most important subsystem (user
interface) last

Big Bang
- No need for drivers and test doubles
- takes longer to locate and fix faults

9. Is it a good practice to have eager tests in our test suite? Why? [2 Marks]
No. Eager test is consider as a test smell.
It makes the test hard to read, hard to maintain, and fault localization is difficult with eager tests.

PAGE 2

UCID

10. Answer only one of the following questions. [3 Marks]


a. Given the following fragment of code, how many tests are required for 100% decision
coverage?
if (width > length) then
biggestDimension = width
if (height > width)
biggestDimension = height
endIf
else
biggestDimension = length
if (height > length)
biggestDimension = height
endIf
endIf

Minimum of 4 tests are required:


1) Height >Width > length
2) Width > Height > length
3) Height > Length > Width
4) Length> Height > Width

b. Given the following code, what is the minimum number of test cases required for full statement
coverage and what is the minimum number of test cases required for full branch coverage?
if (p+q> 100) then
Print "Large"
endIf
if (p > 50) then
Print "p Large"
endIf

1 test for full statement coverage: e.g p = 60, q = 50

2 tests for full statement overage: e.g. p=60, q = 50 , p=40, q = 50

PAGE 3

UCID

11. Consider Saving bank account class with the following functionalities:
Deposit(amount)
i. Adds amount to the balance of the account
Withdraw (amount)
ii. Deducts amount from the balance of the account
CloseMonth()
iii. Calculates the interest rate for the saving account and adds the amount to the balance.
1. Interest is calculated at the end of each month and is calculated base on the minimum
balance of each month.
a) Using equivalence class partitioning (ECP) and boundary value analysis (BVA) techniques drive 5 test cases for
testing Withdraw functionality. Document your test cases with all attributes required for a test case
documentation. [5 Marks]
TC#
1

Scenario
Withdraw

Test Case
Withdraw
negative amount

Test Data
-10$

Steps
Expected Result
Pass/Fail
- Select/create an account with balance = - Exception message
1000$.
Invalid input
- Call withdraw Method with -10 $
- check the message
Withdraw Withdraw
0 0$
- Select/create an account with balance = - Exception message
amount
1000$.
Invalid input
- Call withdraw Method with 0 $
- check the message
Withdraw Withdraw more 1001 $
- Select/create an account with balance = - Exception message
than balance
1000$.
Insufficient amount
- Call withdraw Method with 1001$
- check the message
Withdraw Withdraw valid 10.00 $
- Select/create an account with balance = withdraw
is
positive amount
1000$.
successful
- Call withdraw Method with 10$
- balance of account is
- check remaining balance
decreased by 10 $
Withdraw Withdraw
5.0456 $ - Select/create an account with balance = - Exception message
Invalid amount
1000$.
Invalid input
- Call withdraw Method with 5.0456$
- check the message
b) Using UML class diagram and code given for this class, write one JUnit test for testing closeMonth() function.
Include all details required for a good unit test. Provide comments in the code, if required. [4 Marks]

Account
- owner: String
-balance: double
+ Account(owner:String)
+ deposit(amount: double): void
+ withdraw(amount: double): void
+ closeMonth(): void
+getBalance():double
SavingAccount
-minimumBalance: double
-interestRate: double
+ SavingAccount(owner:String)
+ withdraw(amount: double): void
+ closeMonth(): void
PAGE 4

UCID

public abstract class Account {


private String owner;
private double balance;

public class SavingAccount extends Account{


private double interestRate = 1.5/100;
private double minBalance;

public Account(String owner){


this.owner = owner;
this.balance = 0;
}

public SavingAccount(String owner){


super(owner);
this. minBalance = 0;
}

public void deposit(double amount){


balance = balance + amount;
}

public void withdraw(double amount){


super.withdraw(amount);
double newBalance = getBalance();
if (newBalance < minBalance){
minBalance = newBalance;
}
}

public void withdraw(double amount){


balance = balance - amount;
}
public double getBalance(){
return balance;
}

public void closeMonth(){


double interest =interestRate * minBalance;
deposit(interest);
minBalance = getBalance();
}

public abstract void closeMonth();


}
}
Write your test here:
An example
@Test (timeout = DEFAULT_TIMEOUT)
Public void testCloseMonthWithEmptyAccount(){
SavingAccount acc = new SavingAccount();
Acc.closeMonth();
double expected = 0;
double actual = acc.getBalance();
assertEqual(message, expected, actual, 0.01d)
}

PAGE 5

<< Use this page to write your answers, if you need more space >>

<< Use this page to write your answers, if you need more space >>

You might also like