Shop OBEX P1 Docs P2 Docs Learn Events
Unit Test Framework? — Parallax Forums

Unit Test Framework?

DrGaryDrGary Posts: 7
edited 2007-06-09 06:01 in Propeller 1
For the GPS Smart Mode Object described here, I created a couple of assert functions so I could make add some unit tests.

Unit Tests are collections of functions that test your routines against known values. The idea is that you write tests to ensure the correctness of your code, frequently running the tests to avoid introducing new errors as you write code and to provide confidence in the robustness of the completed code. Best practice requires writing unit tests for as many inputs as you can think of, ensuring that your function works for conditions that could occur, even if rarely, in production. By writing unit tests, you force yourself to account for situations you may gloss over when coding, such as invalid inputs, unwarranted assumptions, etc. The "agile programming" methodology advocates writing the unit tests _before_ writing any code; then you your write code to make the tests pass.

The GPS Smart Mode Object includes a Calendar object for determining Daylight Saving Time. The object and its demo file containing unit tests are attached below.

The unit tests are incomplete and only sketch a proper unit test framework. Can we improve it? How would you build a complete unit test framework? It should:
- include a robust set of assertions
- be able to detect the function/line in which an assertion failed
- include a debug/release switch that prevents the unit test code from taking up valuable memory when 'released'. Perhaps the Unit Test Framework would download to RAM and run, but be omitted when written to EEPROM

Thoughts?
Sign In or Register to comment.