Introduction
- Provides a unified and simple interface that emphasizes the smallest amount of boiler plate code possible.
- The collection and instantiation of its primitives is performed right after the script compilation.
- Within the framework a SINGLE test harness derived class can exist. The harness runs the tests and contains API to access them.
- The test units are compiled to Suites. These provide additional API for environmental control.
Simple tests
Can be perfomed in form of annotated free functions.
Note: Notice the Suite name in the attribute.
[
Test(
"MyFirstTestSuite")]
Base class for test results.
Definition: TestingFramework.c:198
Attribute used for tests annotation and assignment to Suites.
Definition: TestingFramework.c:97
Stateful tests
More elaborate tests that need some state and will run for several ticks have to be defined as TestBase derived classes. Your logic has to be ran through step methods.
Step methods
- You can name your step methods however you like.
- They have to be annotated by the [Step(Stage)] attribute which pairs the step with a stage.
Stages
- They divide the steps into groups that express the initialization and finalization process.
- Stages are executed in order Setup -> Main -> TearDown.
- Methods in stages are executed in order of definition.
Return values
- void -> Will get executed only once.
- bool -> Will get executed every tick until true is returned.
Result
- Result is set via API member method of TestBase
SetResult(TestResultBase)
.
- Setting a result which evaluates to failure will terminate the stage.
Failure unwind
- If the Setup stage fails the test only terminates and TearDown is not called.
- Main stage failure will trigger the TearDown.
- TearDown failure will do nothing.
Timeout
- The tests won't timeout by default. The value may be specified via Test attribute.
- The timeout counter resets for every stage method.
- If the stage method times out the TimeoutResult is set (it evaluates to failure and the failure unwind process starts).
[
Test(
"MyFirstTestSuite", timeoutS: 2, timeoutMs: 250)]
{
void Initialize() { ... }
bool Pool() { ... }
bool FinalizeA() { ... }
void FinalizeB() { ... }
}
EStage
Stage definition used in conjunction with Step attribute.
Definition: TestingFramework.c:115
Attribute which marks a method as part of the testing process.
Definition: TestingFramework.c:124
Test base class.
Definition: TestingFramework.c:178