[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FR-devel] how to test accessor methods (an opinion for DumbTestBuilder)
From: |
gabriele renzi |
Subject: |
[FR-devel] how to test accessor methods (an opinion for DumbTestBuilder) |
Date: |
Mon, 14 Jul 2003 21:44:40 +0200 (CEST) |
hi gurus,
I just made some little change on the wiki to add a
little new feature to DTB.
Now if DumbTestBuilder notices a pair of accessor
methods (i.e. var= and var) it generates a method
named test_accessor_methodname (i.e.
test_accessor_var).
Now, the problem:
We could easily generate code for this testing.. but
this code would probably be wrong.
I mean: suppose this is the test class
class M
def att=(x)
@att=x
end
def att
@att
end
end
we could get this testcase:
class TestM < TestCase
def setup
@tstObject=M.new
end
def test_accessor_att
tmp='something'
@tstObject.att=tmp
assert_equal(tmp,@tstObject.att)
end
end
and this will work fine..
BTW, this code would be of little help:
setup() could fail the creation of class instances,
accessor=(tmp) could cause an exception
and, most important,
if accessor=() and accessor() are explicitly coded it
is quite sure that the input for accessor=() would be
mangled someway, and thus the test would fail..
Should I add this facility?
should I put empty setup() and teardown() methods
anyway in the code?
PS
would rich kilmer please put the slide from oscon on
the wiki ? sounds cool :)
______________________________________________________________________
Yahoo! Mail: 6MB di spazio gratuito, 30MB per i tuoi allegati, l'antivirus, il
filtro Anti-spam
http://it.yahoo.com/mail_it/foot/?http://it.mail.yahoo.com/
- [FR-devel] how to test accessor methods (an opinion for DumbTestBuilder),
gabriele renzi <=