April 2011
Intermediate to advanced
356 pages
8h 55m
English
The simple-minded implementation in the previous chapter gets more robust incrementally. Each test drives the implementation to a more complete state.
The next test turns on a couple of LEDs. That is enough to force a more general and complete implementation. Notice which LEDs are turned on in the test that follows, and see if you can easily determine whether the expected value in virtualLeds is correct.
| unity/LedDriver/LedDriverTest.c | |
| | TEST(LedDriver, TurnOnMultipleLeds) |
| | { |
| | LedDriver_TurnOn(9); |
| | LedDriver_TurnOn(8); |
| | TEST_ASSERT_EQUAL_HEX16(0x180, virtualLeds); |
| | } |
Tests are documentation, and a good document should be easy to understand. If you want well-written tests, you must carefully select ...