Skip to content

Commit 9f76adb

Browse files
authored
Merge pull request #91 from fflorent/document-how-to-run-tests
Document how to run the tests inside the container
2 parents a3dc4b7 + b2b562f commit 9f76adb

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Please report issues on the following repository: <https://github.com/yunohost/i
1414
- [2. Manage YunoHost's dev LXCs](#2-manage-yunohosts-dev-lxcs)
1515
- [3. Development and container testing](#3-development-and-container-testing)
1616
- [4. Testing the web interface](#4-testing-the-web-interface)
17+
- [5. Running the automated tests](#5-running-the-automated-tests)
1718
- [Advanced: using snapshots](#advanced-using-snapshots)
1819
- [Troubleshooting](#troubleshooting)
1920
- [Remote Development Environment](#remote-development-environment)
@@ -233,6 +234,47 @@ Note that `./ynh-dev use-git yunohost-admin` has a particular behavior: it start
233234
that shall re-compile automatically any changes in the javascript code. Hence this particular `use-git`
234235
will keep running until you kill it after your work is done.
235236

237+
### 5. Running the automated tests
238+
239+
In packages like `yunohost`, you have automated non-regression tests at your disposal (that you may change if you want to suggest changes).
240+
241+
> [!TIP]
242+
> You might be interested in creating a separate incus container to run your tests than for the one you use for packages
243+
>
244+
> In such case, you may initiate or attach the container with a specific name, like:
245+
>
246+
> ```bash
247+
> ./ynh-dev start bookworm ynh-test
248+
> ```
249+
>
250+
> And run `yunohost tools postinstall` like for the other container.
251+
252+
To run the tests, assuming you have already run `./ynh-dev use-git PKG` within the container, you can use the following command:
253+
254+
```bash
255+
./ynh-dev test PKG
256+
```
257+
258+
For example, to run all Python tests for Yunohost (excluding bash helper tests):
259+
260+
```bash
261+
./ynh-dev test yunohost
262+
```
263+
264+
To run tests for a specific file, such as `tests/test_appurl.py`:
265+
266+
```bash
267+
./ynh-dev test yunohost appurl
268+
```
269+
270+
Or, to run a specific test function, like `test_urlaavailable()` within the `tests/test_appurl.py` file:
271+
272+
```bash
273+
./ynh-dev test yunohost/appurl:urlavailable
274+
```
275+
276+
Note that `./ynh-dev test` automatically installs the necessary dependencies (`pip`, `pytest`, `mock`) for test execution.
277+
236278
### Advanced: using snapshots
237279

238280
You can check `incus snapshot --help` to learn how to manage incus snapshots.

0 commit comments

Comments
 (0)