OU Courese Banner ADBH Web - M206 TMA05 Question 1 part 2
ADBH Web 05-Sep-2008

M206 - TMA05 - Question 1 Part 2

ii) Project II - Stage 1 Posting okToPayinterest

Check if it is Ok to pay interest, answer true if 180 days or more have passed since the account was applied for and the account has a balance greater than 0, answer false either of the conditions are not met."

  • (Date today asDays - self dateAppliedFor asDays >= 180 and:[self balance > 0])
  • ifTrue:[^true]
  • ifFalse: [^false].

(iii) Project 11 Stage 2 Posting - Code Testing Omission from my Test Strategy Posting. ( Extract from Stage III Posting 4)

While preparing the TMA 1 was checking though my rough notes and the workspace I've noticed 1 missed out one of the tests performed. The test was balance:100 where the '00' is uppercase character 'o' this was to simulate inadvertent use of 'o' instead of zero - it produced the dialog '00' is a new message (same dialog as for creating variables).

The code to test from Student A is as follows:

  • ^((Date today subtractDate: dateAppliedFor)>180) & (balance> 0)

The Strategy for testing the code

The instance method okToPayInterest is required to cheek the values of dateAppliedFor and balance of a KidsAccount instance and produce a true answer if the date is at least 180 days greater than the dateAppliedFor and the account is in credit else answer false.

a) To test this code first creates an instance of KidsAccount (testAcc1 ) and set the variables to some normal values as follows:

  • testAccl := KidsAccount new.
  • testAccl holder: 'Test Account 1';overLimit: 50; credit: 50;
  • dateAppliedFor: (testDate 1:= Date newDay:22 month:#May year: 1998).

b) Create a second instance of KidsAccount (testAcc2) using similar code to above but using different variable values and testDate2 as Date instance. This will be used to check for interaction between instances of KidsAccount and will be inspected after every change to testAcc1. There should not be any chances to testAcc2 caused by changes to testAccl.

c ) Next create variables with dates set at the boundary values of the condition to be tested.

d) Set dateAppliedFor to a date value and set the balance to all of its boundary values in turn, then repeat the process using the next date value.

e) After every change in dateAppliedFor or balance , inspect testAcc1 and verify values are as expected.

f) Check the message answer after each testAcc1 okToApplyinterest evaluation.

Test Code DATE Expressions

testDate181:=(Date today)subtractDays:181.

'181 days ago

testDate180:=(Date today)subtractDays:l 80.

'180 days ago

testDate179:=(Date today)subtractDays:179.

'179 days ago

testDatefuture: =(Date today) addDays:l

'Tomorrow

testDateinvalid:='22106199'

'Invalid date which in effect produces today's date

 

Test Code BALANCE Expressions

testAcc1

balance: 0.

'Set balance to zero.

testAcc1

balance: 0.1.

'Set balance greater than zero.

testAcc1

balance:-0.1

'Set balance greater than zero.

testAcc1

balance: nil.

'Test for unset account balance.

testAcc1

balance: 'One'

'Test for non numerical values.

TEST RESULTS Note : Though not shown in the results for clarity testAcc1 balance: xxxx produced a message answer of 'a KidsAccount' which was correct, this being true in all cases. testAcc1 dateAppliedFor: testDate181. 'Tests all test values of balance at the 181 day boundary. Inspect testAcc1 and confirm dateAppliedFor is 181 days ago before proceeding. dateAppliedFor confirmed as 181 days ago.

Expression Series

Expected

Actual

Result

testAcc1 balance: 0.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 0.1.

 

 

 

testAcc1 okToPayinterest

true

true

correct

testAcc1 balance: -0.1.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: nil.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 'One'.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 dateAppliedFor: testDate180. 'Tests all test values of balance at 180 day boundary. Inspect testAcc1 and confirm dateAppliedFor is 180 days ago before proceeding. dateAppliedFor confirmed as 180 days ago.

Expression Series

Expected

Actual

Result

testAcc1 balance: 0.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 0.1.

 

 

 

testAcc1 okToPayinterest

true

false

incorrect

testAcc1 balance: -0.1.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: nil.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 'One'.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 dateAppliedFor: testDate179. 'Tests all test values of balance at 179 day boundary. Inspect testAcc1 and confirm dateAppliedFor is 179 days ago before proceeding. dateAppliedFor confirmed as 179 days ago.

Expression Series

Expected

Actual

Result

testAcc1 balance: 0.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 0.1.

 

 

 

testAcc1 okToPayInterest

false

false

correct

testAcc1 balance: -0.1.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: nil.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 'One'.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 dateAppliedFor: testDatefuture 'Test future dates at all values of balance test data. Inspect testAcc1 and confirm dateAppliedFor is tomorrows date before proceeding. dateAppliedFor confirmed as tomorrows date. Course M206Assignment M206 TMA 05

Expression Series

Expected

Actual

Result

testAcc1 balance: 0.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 0.1.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: -0.1.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: nil.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 'One'.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 dateAppliedFor: testDateinvalid 'Test for invalid dates at all values of balance test data. Inspect testAcc1 and confirm dateAppliedFor is todays date before proceeding. dateAppliedFor confirmed as todays date.

Expression Series

Expected

Actual

Result

testAcc1 balance: 0.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 0.1.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: -0.1.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: nil.

 

 

 

testAcc1 okToPayinterest

false

false

correct

testAcc1 balance: 'One'.

 

 

 

testAcc1 okToPayinterest

false

false

correct

Results Summary

testAcc1 balance: nil. and testAcc1 balance: 'One'. produced false results in all cases as expected. testAcc2 was never affected by changes to testAcc1 Course M206Assignment M206 TMA 05

Date

Balance

Expected

Actual

Result

today

-0.1

false

false

correct

today

0

false

false

correct

today

0.1

false

false

correct

179 days ago

-0.1

false

false

correct

179 days ago

0

false

false

correct

179 days ago

0.1

false

false

correct

180 days ago

-0.1

false

false

correct

180 days ago

0

false

false

correct

180 days ago

0.1

true

false

incorrect

181 days ago

-0.1

false

false

correct

181days ago

0

false

false

correct

181 days ago

0.1

true

true

correct

From the results summary it can be seen that Student A's code fails to deal correctly with the 180 day with account in credit' test. All other tests were passed satisfactorily

iv) Here are my observations for the evaluation of Student B's testing strategy for oKToPayinterest".

The tests for testing dates around the boundary and mid range values were good in as far as it goes. However Student B only appears to have tested using only two values of balance ( 0 & 100) . Therefore he has neglected to test the boundary values of balance i.e. -0.1 , 0 and 0.1 and values of balance at nil and XXXX (XXXX represents any non numerical value and is most likely to be caused by a typo). The tests should have covered all combinations of dateAppliedFor and balance.

Student B's account does not state whether or not the instance of 'KidsAccount was inspected after each evaluation to confirm that its state was as expected. There also appears to be no check on the KidsAccount instance state after Interest message was sent. I would also have liked to see a second instance of KidsAccount to test that oKToPayinterest made no changes in state to this instance.

In my opinion this was a weak testing strategy.

Question 1a - Question 1c

Top of Page

 

 

 

Page built in 0.0021 seconds