20 August 2007

AtomicObject use mocks for Embedded C

At Agile 2007 I chaired an experience report session which had an elegant paper from AtomicObject on their approach to developing code for embdedded systems in C. The relevant bit for this blog is their use of interaction testing.

To make up for the lack of reflection in C, they defined conventions for their header files and wrote Ruby scripts in Rake to generate mocks and link in the right code for the unit tests.

Why did they go to all this trouble? In their words

our mocks revealed that some of the code was making calls it shouldn't have been
The mocks also helped us enforce single responsibility. Whenever the tests for a piece of code got too complicated, we could usually find a good way to break some of the complexity out into another module.

and from the presentation:

Interaction-based testing made tests easier to write and less brittle

It's nice to see the ideas port to a significantly different environment

No comments: