Unit Testing

Summary of the Sandi Metz video about unit testing. Video is here:

http://www.youtube.com/watch?v=URSWYvyc42M

Message

Query

Command

Incoming

Test by making assertions about what they send back, even if other objects are used internally

Test by making assertions about direct(last class involved) public side effects

Internal

Do not test. Do not make assertions about their result. Do not expect to send them

Outgoing

Do not test. Do not make assertions about their result. Do not expect to send them. If a message has no visible side effects, the sender should not test it.

Expect to send outgoing command messages. Break rule if side effects are stable and cheap

The tests for outgoing command messages make a bet that the nearest object which the object under test interacts with will have a stable API.

You need to make sure that your test doubles stay in sync with the API. Help with that :

UnitTesting (last edited 2013-11-28 03:07:08 by DesmondRivet)