Professional Documents
Culture Documents
Quiz1 SENG437 AnswerKey
Quiz1 SENG437 AnswerKey
Full Name
Solution
UCID
Good luck!
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
True
True
False
False
False
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
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
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
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 >>