[RPS] Testing - first attempt

Chris Roos chris at seagul.co.uk
Wed May 4 02:03:49 EDT 2005


Hi again,

First off, please note that this isn't me going against protocol and not 
requesting responsibility for the test first of all; rather I just 
wanted to ask a couple of general questions about the tests required 
(and have included a test to support those questions).

I've been taking a quick look at the ts_payment.rb test suite and 
started on the first test for Payment::Base, namely test_account_number.

I notice (and as confirmed by the zentest site) that two tests are 
created automatically for the attr_accessor :account_number.
1) test_account_number
2) test_account_number_equals

My first question is whether we need to (and feasibly can) test the 
read/write methods seperately, or whether we can cover these off in one 
test method?

At present, I have just implemented two asserts in the body of the 
test_account_number test as follows..

TestBase.test_account_number
   def test_account_number
     base = Payment::Base.new( :account_number => 'cjr123' )
     assert(base.account_number == 'cjr123')
     base.account_number = 99
     assert(base.account_number == 99)
   end

The first ensures that we can supply an account_number in the 
constructor, as all the constructor will do is check that we include a 
method called (in this case) "account_number=" and assign to it.  The 
second then manually assigns using the "account_number=" method.  I have 
also tested the assignment of numeric and string account numbers.

The output of this is as follows
$ ruby ts_payment.rb -n test_account_number
# 1 tests, 2 assertions, 0 failures, 0 errors

Does this test provide sufficient proof at this stage or do we need to 
do more?

I hope I'm on roughly the right track with what I've looked at so far 
and I look forward to hearing your thoughts.

Chris



More information about the Therps-discuss mailing list