@@ -7,14 +7,24 @@ In this guide, we'll learn how to set up a testing suite for a Lua project.
7
7
8
8
## Creating Spec Files
9
9
10
- By default, Lux uses [ ` busted ` ] ( https://github.com/lunarmodules/busted ) as its testing suite.
11
- Tests are stored in a ` spec/ ` directory in the root of your project, and only files
10
+ By default, will try to auto-detect your test suite.
11
+ If there is a ` .busted ` file in your project root,
12
+ Lux will use[ ` busted ` ] ( https://github.com/lunarmodules/busted ) as its test backend.
13
+ Otherwise, you must specify the test backend in your ` lux.toml ` :
14
+
15
+ ``` toml title="test specification"
16
+ [test ]
17
+ type = " busted"
18
+ ```
19
+
20
+ With busted, tests are stored in a ` spec/ ` directory in the root of your project, and only files
12
21
ending in ` _spec.lua ` are considered tests.
13
22
14
23
The type of tests you will make will vary greatly depending on the type of project at hand.
15
24
Nevertheless, refrain from making trivial tests - they bring little value to a codebase.
16
25
17
26
Below is an example of a test:
27
+
18
28
``` lua title="spec/request_parse_spec.lua"
19
29
local request = require (" mylib.request" )
20
30
local json = require (" mylib.json" )
@@ -76,3 +86,9 @@ return {
76
86
```
77
87
78
88
For full reference, see [ the ` busted ` website] ( https://lunarmodules.github.io/busted ) .
89
+
90
+ ## Alternate test backends
91
+
92
+ You don't have to use ` busted ` as a test backend.
93
+ See the test section in [ How to declare a lux.toml file] ( /guides/lux-toml )
94
+ for alternate test backends.
0 commit comments