| 1 |
# polkit integration test suite |
| 2 |
|
| 3 |
polkit's integration test suite uses TMT (Test Management Tool [0]) to organize and run tests. Since TMT |
| 4 |
offers a _lot_ of features, this document pinpoints the most _interesting_ ones to get stuff up and running |
| 5 |
quickly. |
| 6 |
|
| 7 |
## How to contribute |
| 8 |
|
| 9 |
Creating a new test case is pretty simple: |
| 10 |
|
| 11 |
``` |
| 12 |
$ cd test/integration |
| 13 |
$ tmt test create --template=shell test/name |
| 14 |
Test directory '/home/.../polkit/test/integration/test/name' created. |
| 15 |
Test metadata '/home/.../polkit/test/integration/test/name/main.fmf' created. |
| 16 |
Test script '/home/.../polkit/test/integration/test/name/test.sh' created. |
| 17 |
``` |
| 18 |
|
| 19 |
The newly created `test.sh` will be the actual test case, and `main.fmf` contains the test metadata, including |
| 20 |
test summary & description, test dependencies, runtime, and so on. See [1] for more details. |
| 21 |
|
| 22 |
After tweaking the test metadata it's usually a good idea to run `tmt lint test/name` to make sure that the |
| 23 |
configuration is still valid: |
| 24 |
|
| 25 |
``` |
| 26 |
$ tmt lint test/name |
| 27 |
/test/name |
| 28 |
pass C000 fmf node passes schema validation |
| 29 |
pass C001 summary key is set and is reasonably long |
| 30 |
... |
| 31 |
``` |
| 32 |
|
| 33 |
To check if the test itself works as expected you can use `tmt run`: |
| 34 |
|
| 35 |
``` |
| 36 |
$ cd test/name |
| 37 |
$ tmt run -vvv --all provision --how local --feeling-safe tests --name . |
| 38 |
... |
| 39 |
total: 1 test passed |
| 40 |
``` |
| 41 |
|
| 42 |
The `tmt run` command is _very_ customizable (as is the rest of `tmt`). In this particular example we tell it |
| 43 |
to run all steps (`--all`) and override the `provision` and `tests` steps to run just one particular test on |
| 44 |
the local machine. As in previous cases, check the `tmt` documentation [0] and examples [2] for more details. |
| 45 |
|
| 46 |
## Links |
| 47 |
|
| 48 |
[0] https://tmt.readthedocs.io/en/stable/overview.html |
| 49 |
|
| 50 |
[1] https://tmt.readthedocs.io/en/stable/spec/tests.html |
| 51 |
|
| 52 |
[2] https://tmt.readthedocs.io/en/stable/examples.html#run |
| 53 |
|
| 54 |
<!-- vim: set syntax=markdown tw=110 : --> |