Execution
The command gox test discovers, compiles and executes the tests declared in the project.
By default, GOX search recursively for all files .gox within tests/ and executes its completed functions in Test.
Use
gox test [files] [options] | Option | Description |
|---|---|
-run <pattern> | Run the tests whose name matches the pattern. |
-bench <pattern> | It runs Benchmarks whose name matches the pattern. |
--v | Print the detailed result of each execution. |
-out <file> | Write the overall result on JSON. |
All tests
gox test The files and functions are run in alphabetical order. PASS or FAIL for each function.
Select Files
It is possible to provide a file or folder:
gox test tests/index.gox
gox test tests/session The folders are rotated recursively. The relative routes are resolved from the project and can be written with or without the prefix tests/.
Filter tests
-run accepts a regular expression applied to the name of the function:
gox test -run IndexTest
gox test -run 'Session.*Test' A file selection can also be combined with the filter.
Detailed output
gox test --v --v print the JSON representation of each result recorded by test.Execute(). To interpret your steps and diagnoses Results.
Global report
gox test -out report.json The relative routes of -out are written within tests/The report includes the files executed, the tests, their results, the duration and the totals of success or failure.
test.Save() has an individual result and is documented in Results.
Benchmarks
gox test -bench IndexTest -run and -bench cannot be used simultaneously. Benchmarks to know the settings and the available metrics.
Options not available
The runner recognizes -race, -cpuprofile and -memprofilebut they are not yet implemented. If used, gox test ends with an error instead of running the tests.
Best practices
- Run the complete set before integrating changes.
- Use
-runduring the development of a particular case. - It uses descriptive test names to facilitate filters.
- Save global reports only when you need to process or keep them.
- Do not use options marked as not implemented.