Updating documentation

This commit is contained in:
Peter Slattery 2023-11-10 12:58:50 -08:00
parent d3aa58655a
commit f8af3e59f4
1 changed files with 20 additions and 1 deletions

View File

@ -6,6 +6,25 @@ Framework for test implementation + test discovery in jai
This Jai Module provies a means of writing tests and building a test executable
that can be used in applications such as CI runners.
## Test Executable Reference
Test executables can be run individually or via `run_all_tests.sh` which is output in the same directory.
Both tests and `run_all_tests.sh` have the same options:
`-colors`: output colored information for easier readability
`-verbose`: by default the output will only show test suites run, and full information on errors. Enabling verbose output indicates all tests that are run as well.
## Test Harness Reference
`Init_Test_Harness(suite_name: string)`: Call at the beginning of your test suite function to initialize the test suite.
`Run_Test_Harness()`: Call at the end of your test suite function to execute all tests
`Before_Each(#type () -> ())`: Define a function that will be run before each test
`After_Each(#type () -> ())`: Define a funciton that will be run after each test
`Test(test_name: string, test_proc: #type () -> ())`: Define a single test function
`expect(received, expected)`: Checks for equality between the two values. Equivalent to `if (received != expected) report_test_failure()`
`expect_true(value)`
`expect_false(value)`
## How It Works
1. You call `gs_test.build_all_tests` from your build script
@ -19,7 +38,7 @@ You can call `run_all_tests` in CI and it will output an error code if any tests
1. Put gs_test somewhere where your jai compiler can find it.
ie. `C:\jai\modules\gs_test`
2. Copy the two examples below into files in the same directory
2. Copy the two examples below into files in a sample project directory
3. Run `jai -import_dir C:\jai\modules build.jai`
4. Run `./tests/run_all_tests.sh` (you might need to give it execute permissions first)