1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

docs: add a note about test files being compiled as separate V programs, independently from normal code

This commit is contained in:
Delyan Angelov 2022-12-19 13:15:39 +02:00
parent 353fdb4ca0
commit bcdf1b95c1
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -4291,9 +4291,14 @@ fn test_hello() {
assert hello() == 'Hello world'
}
```
To run the test above, use `v hello_test.v`. This will check that the function `hello` is
To run the test file 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.
Note: all `_test.v` files (both external and internal ones), are compiled as *separate programs*.
In other words, you may have as many `_test.v` files, and tests in them as you like, they will
not affect the compilation of your other code in `.v` files normally at all, but only when you
do explicitly `v file_test.v` or `v test .`.
* All test functions have to be inside a test file whose name ends in `_test.v`.
* 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