Friday, May 29, 2009

RSpec book

Test Behaviour Not Internal Structure

Unit Tests can be brittle in that they use internals of an object (eg. check register() method works by checking something was added to an internal array). If we change internals, test will fail even though behaviour hasn't changed. How can we avoid tying our unit tests to internals?

Design the API by using it

When writing code, call methods you wish you had - then you can implement them. Better than designing the API on its own.

No comments: