Testing Framework - PathogenDavid/Periodic GitHub Wiki

Unfortunately, Sifteo offers no testing framework. We considered retargeting our codebase to Windows and testing with an already established framework, but we opted for making a very simple testing framework for Sifteo cubes instead. This testing framework is independent of our project, and can easily be used in other Sifteo cube projects.

Tests are built as extremely bare-bones Sifteo applications, which are then run in the Siftulator (Sifteo cube emulator) by TestRunner. Test results and messages are sent over standard Sifteo debug log. All test framework-related messages are prefixed with "TEST: " in order to help them stand out against the debug spam the Siftulator normally produces.

Test Organization

A single Sifteo application is used to execute several test steps. Each TestStep is intended to be its own function and file. The output of separate TestSteps are separated by a log message, but otherwise no type of separation is done, they are currently a formality of test development.

New test steps should be added to both TestSteps.h as well as the main function in main.cpp.

Extra organization can be done by using the TestMessage macro, which prints a message to the log. This message will have no bearing on the pass/fail verdict of the tests.

Comparisons

Right now comparisons are limited as we've only been added over time as deemed necessary. Currently only verifying equality is possible, and only between unsigned integers, integers, booleans, and strings.

Here is a list of the relevant comparison macros:

  • TestEqUint
  • TestEqInt
  • TestEqBool
  • TestEqString

All of the macros take the format `Test(, , )

You can also force a test failure using the TestForceFail macro.

Test failure

Test failure occurs when one or more comparisons fail to verify, or a test failure is forced by some test. When a verification fails, details about the failure will be emitted. (Currently, when a verification succeeds, nothing is printed.)

The TestIsFailing function can be used to check if the test is currently failing programatically.

The test pass/fail verdict is printed at the end of execution as either !!!TEST FAILURE!!! or !!!TEST PASSED!!!.

When running under TestRunner, the test verdict will be further validated and printed in large letters to the console.

⚠️ **GitHub.com Fallback** ⚠️