Test files

    To run the test above, use v hello_test.v. This will check that the function hello is producing the correct output. V executes all test functions in the file.

    • Test function names must begin with test_ to mark them for execution.
    • Normal functions can also be defined in test files, and should be called manually. Other symbols can also be defined in test files e.g. types.
    • There are two kinds of tests: external and internal.
    • External tests must import the modules which they test. They do not have access to the private functions/types of the modules. They can test only the external/public API that a module provides.

    You can also define special test functions in a test file:

    • testsuite_begin which will be run before all other test functions.
    • testsuite_end which will be run after all other test functions.

    Running tests

    To test an entire module, use v test mymodule. You can also use to test everything inside your current folder (and subfolders). You can pass the -stats option to see more details about the individual tests run.