From: Philipp Meier Date: 2002-10-04T01:44:20+09:00 Subject: Re: Reusing base classes tests? --jRHKVT23PllUwdXP Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 04, 2002 at 01:26:01AM +0900, Phlip wrote: > coma_killen@fastmail.fm wrote: >=20 > > Whats the standard way to reuse the Test::Unit tests for a > > base class when deriving a subclass? Should the testcase > > class derive from the base class testcase class or are there > > better ways? >=20 > The best way I have found is to inherit, then create the testee in a meth= od=20 > called 'warmUp'. Then override that method. Don't call 'warmUp' from=20 > 'initialize'. >=20 > This page does not contain enough: >=20 > http://c2.com/cgi/wiki?AbstractTest >=20 > Test rigs are pragmatic, not magic. Put another way, Liskov Substitution= =20 > Principle applies between the base and derived test, so the system should= =20 > >not< be able to tell the difference between a test method that calls=20 > 'warmUp' and one that does not. LSP in the tests does not mean everyone= =20 > must call 'warmUp'. >=20 > Classes, however, should follow LSP, so tests a base class should pass th= e=20 > derived class should pass too. I think I lost you here. Assume the following class Vehicle end class Car def wheels return 4 end end class Truck def wheels return 8 end end class CarTest def test_wheels assert_equal(4,testee.wheels) end end How should Truck pass CarTest? Or should TruckTest inherite from CarTest and override test_wheels? Whould this be according to LSP? -billy. --=20 Meisterbohne S=F6flinger Stra=DFe 100 Tel: +49-731-399 499-0 eL=F6sungen 89077 Ulm Fax: +49-731-399 499-9 --jRHKVT23PllUwdXP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iD8DBQE9nHPgfBriNoqItSYRAlC/AJ408a780Le2SiMLt8GojFT8U2x4GQCbBG7y vx/r13tgS7dwyHOG8axMc58= =GWlz -----END PGP SIGNATURE----- --jRHKVT23PllUwdXP--