diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-30 11:33:50 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-30 11:33:50 -0400 | 
| commit | dada1b364d99cdff627fba701aede00b713e61fd (patch) | |
| tree | 9c27f1e7dcf76a8b9d2aba85dfa2322ae8eabb6d | |
| parent | aee3c2d4089cfab235eaa66665ddf7dee76b2933 (diff) | |
| download | stasis-dada1b364d99cdff627fba701aede00b713e61fd.tar.gz | |
Add tests/README.md
| -rw-r--r-- | tests/README.md | 48 | 
1 files changed, 48 insertions, 0 deletions
| diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..bb1f896 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,48 @@ +# Testing STASIS + +## Unit tests + +Rules: + +* Use the boilerplate `_test_boilerplate.c` +  * ```shell +    cp _test_boilerplate.c test_mynewtest.c +    ``` +* Test file names start with `test_` (`test_file.c`) +* Test functions start with `test_` (`void test_function()`) +* Test suites can be skipped by returning `127` from `main()` +* PASS, FAIL, and SKIP conditions are set by the assertion macros `STASIS_{ASSERT,ASSERT_FATAL,SKIP_IF}` +* Parametrized tests should implement an array of `struct testcase` +  * The `testcase` structure should be local to each `test_` function +  * The `testcase` variables are freeform +  * Example: +    ```c +    void test_function() { +        struct testcase { +            int your; +            int variables; +            int here; +        }; +        struct testcase tc[] = { +            {.your = 0, .variables = 1, .here = 2}, +            {.your = 3, .variables = 4, .here = 5}, +            // ... +        }; +        for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { +            // STASIS_ASSERT()s here +        } +    } +    ``` +     +## Regression test (RT) + +Rules: + +* Regression tests are shell scripts (BASH) +* Use the boilerplate `_rt_boilerplate.sh` +  * ```shell +    cp _rt_boilerplate.sh rt_mynewtest.sh +    ``` +* Test file names start with `rt_` (`rt_file.sh`) +* Test function names are freeform, however they must be executed using `run_command()` (`run_command test_function`) +* Test suites can be skipped by returning `127` from the shell script
\ No newline at end of file | 
