Skip to main content

Test-environments

Although tests can be used directly inline as shown above, it is useful to organize them inside a scoped environment called testenv. This environement keeps track of some test statistics, which get printed to stdout. Here is an example

To evaluate the tests in the testenvironment, you need to run terra with the command-line-option --test or -t

terra test3.t --test

which prints out

Test Environment: my test environement

inline tests:
3/5 tests passed
2/5 tests failed

test failed in test3.t, linenumber 13
test failed in test3.t, linenumber 15

Notice that the test environment is given a name, which gets printed to stdout. Lua variables may be directly declared and terra variables are declared inside a terracode block, which is just a collection of terra statements, not scoped environement. Notice that terra variables and lua variables may be logically combined and that lexical scoping rules apply.

Important

Test-environments are isolated from one another preventing unintended interference between tests.