Debian Codegraph @

tests/README.md

raw symbols SCIP
1 # Castle Tester
2
3 Using [Castle Game Engine](https://castle-engine.io/).
4
5 ## Castle Game Engine testing framework
6
7 This application runs a number of automatic tests defined in `code/testcases/`.
8
9 It uses _Castle Game Engine_ testing framework, which is based on https://wiki.freepascal.org/fpcunit[FPCUnit] which is in turn inspired by DUnit, JUnit. Features above FPCUnit:
10
11 - We add some CGE-specific assertions (to compare vectors, matrices),
12 - We add a way to display test output using `TCastleWindow`,
13 - We work with both FPC and Delphi,
14 - The test application runs on all platforms we support (desktop, mobile, consoles, soon also web). So you can run tests e.g. on a real Android device.
15
16 ## Building
17
18 Build it like a usual CGE project:
19
20 - From [CGE editor](https://castle-engine.io/manual_editor.php). Just use menu item _"Compile"_.
21
22 - Or use [CGE command-line build tool](https://github.com/castle-engine/castle-engine/wiki/Build-Tool). Run `castle-engine compile` in this directory.
23
24 - Or use [Lazarus](https://www.lazarus-ide.org/). Open in Lazarus `castle_tester_standalone_standalone.lpi` file and compile / run from Lazarus. Make sure to first register [CGE Lazarus packages](https://castle-engine.io/lazarus).
25
26 - Or use [Delphi](https://www.embarcadero.com/products/Delphi). Open in Delphi `castle_tester_standalone_standalone.dproj` file and compile / run from Delphi. See [CGE and Delphi](https://castle-engine.io/delphi) documentation for details.
27
28 ## Running tests from GUI
29
30 By default the tester shows a window using `TCastleWindow`. Run by just running `castle-tester` binary. Press _"Start"_ button to run all the tests.
31
32 ## Running tests from console (command-line)
33
34 Run with `--console` option to output to the console instead. Aside from changing the output, it also changes a bit how tests are executed: on a first uncaught exception, the tests stop, with a backtrace pointing to the exception. Like this:
35
36 ```
37 castle-engine compile --mode=debug
38 ./castle-tester --console
39 # or:
40 # castle-engine run -- --console
41 ```
42
43 You can also run with `--no-window-create` to avoid making tests that require to create a new window, thus making it possible to run tests when no graphic environment is available. This is good for testing inside e.g. a server without GUI, or a Docker container.
44
45 ```
46 ./castle-tester --console --no-window-create
47 ```
48
49 ## Filtering
50
51 You can pass command-line parameter `--filter` to filter the initially enabled tests. Given filter can use wildcards (`*` and `?`) and is compared with the test name, which is the test case class name + test method name, separated by dot, like `TTestCastleClassUtils.TestRleCompression`. The comparison ignores case (since in Pascal identifiers, case is ignored). E.g.
52
53 - use `"--filter=TTestCastleClassUtils.*"` to run all tests from the `TTestCastleClassUtils` test case.
54 - use `--filter=TTestCastleClassUtils.TestRleCompression` to run exactly this particular test.
55 - use `"--filter=*image*"` to run all tests that have `image` in their name.
56
57 Note that it makes sense to add quotes (single or double) around the command-line option, to avoid shell from interpreting the `*` and `?` characters. Though you are unlikely to have any files matching the `--filter...`, so it should not be a problem. Unless you use space to separate `--filter` to option argument like `*image*`, then the quotes matter.
58
59 This filtering is applied to both console and GUI operation.