|
1 |
| -# Running tests: |
2 |
| -================ |
3 |
| -**These tests are written for `pytest`** |
| 1 | +# Code testing |
| 2 | +All the tests are written using the `pytest` unit testing framework. Code coverage is provided by `pytest-cov` |
4 | 3 |
|
5 |
| -- Make sure you're in the iocage directory |
6 |
| -- Supply --zpool="POOL" to pytest |
| 4 | +Before running tests, test dependencies can be installed by running: |
| 5 | +``` |
| 6 | +$ pip install pytest-cov pytest-pep8 |
| 7 | +``` |
| 8 | + |
| 9 | +## Unit tests |
| 10 | + |
| 11 | +Located in the ``tests/unit_tests`` directory, they can be started as a normal user with the following command: |
| 12 | + |
| 13 | +``` |
| 14 | +$ pytest |
| 15 | +``` |
| 16 | + |
| 17 | +## Functional tests |
| 18 | + |
| 19 | +Located in the ``tests/functional_tests``, they need a root acces and the name of a ZFS pool |
7 | 20 |
|
8 |
| -#####Example: |
| 21 | +**/!\ The contents of the specified ZFS pool will be destroyed** |
| 22 | + |
| 23 | +To start the functional tests, run pytest with root privileges and the name of a zpool: |
9 | 24 | ```
|
10 |
| -git clone https://github.com/iocage/iocage.git |
11 |
| -cd iocage/iocage |
12 |
| -sudo pytest --zpool="TEST" --server="custom_server" |
| 25 | +$ sudo pytest --zpool=mypool |
13 | 26 | ```
|
14 | 27 |
|
15 |
| -**To list all supported fixtures to pytest:** |
16 |
| -`pytest --fixtures` |
| 28 | +Other parameters are available, to see them run: |
| 29 | +``` |
| 30 | +$ pytest --fixtures |
| 31 | +``` |
| 32 | +Extract: |
| 33 | +``` |
| 34 | +zpool |
| 35 | + Specify a zpool to use. |
| 36 | +release |
| 37 | + Specify a RELEASE to use. |
| 38 | +server |
| 39 | + FTP server to login to. |
| 40 | +user |
| 41 | + The user to use for fetching. |
| 42 | +password |
| 43 | + The password to use for fetching. |
| 44 | +root_dir |
| 45 | + Root directory containing all the RELEASEs for fetching. |
| 46 | +http |
| 47 | + Have --server define a HTTP server instead. |
| 48 | +hardened |
| 49 | + Have fetch expect the default HardeneBSD layout instead. |
| 50 | +_file |
| 51 | + Use a local file directory for root-dir instead of FTP or HTTP. |
| 52 | +auth |
| 53 | + Authentication method for HTTP fetching. Valid values: basic, digest |
| 54 | +``` |
| 55 | + |
| 56 | + |
| 57 | +#Example |
| 58 | +``` |
| 59 | +$ git clone https://github.com/iocage/iocage.git |
| 60 | +$ cd iocage/iocage |
| 61 | +$ sudo pytest --zpool="TEST" --server="custom_server" |
| 62 | +``` |
0 commit comments