|
| 1 | +By default, the unit tests will run automatically when the [GitHub workflows](https://github.com/MicroPythonOS/MicroPythonOS/tree/main/.github/workflows) are triggered. |
| 2 | + |
| 3 | +But when you're working on a unit test, or investigating a failure, you probably want to run it locally for quick iteration. |
| 4 | + |
| 5 | +The tests are stored in [tests/](https://github.com/MicroPythonOS/MicroPythonOS/tree/main/tests) |
| 6 | + |
| 7 | +Simple (non-graphical) test filenames start with `test_` and ends with `.py`. |
| 8 | + |
| 9 | +Graphical tests start with `test_graphical_` and also end with `.py`. |
| 10 | + |
| 11 | +# On Desktop |
| 12 | + |
| 13 | +The following assumes you have MicroPythonOS running on desktop, meaning this works: |
| 14 | + |
| 15 | +``` |
| 16 | +./scripts/run_desktop.sh |
| 17 | +``` |
| 18 | + |
| 19 | +Then you can run a specific unit test by providing its file as an argument: |
| 20 | + |
| 21 | +``` |
| 22 | +./tests/unittest.sh tests/test_package_manager.py |
| 23 | +``` |
| 24 | + |
| 25 | +To run all unit tests, do: |
| 26 | + |
| 27 | +``` |
| 28 | +./tests/unittest.sh |
| 29 | +``` |
| 30 | + |
| 31 | +This takes some time, during which you'll see the MicroPythonOS window pop up often. |
| 32 | + |
| 33 | +There's also a syntax checker: |
| 34 | + |
| 35 | +``` |
| 36 | +./tests/syntax.sh |
| 37 | +``` |
| 38 | + |
| 39 | +# On Device |
| 40 | + |
| 41 | +The unit tests can also run on a physical device, like an ESP32 that's connected with a USB cable, which is more representative and can help to test features that are not available on desktop. |
| 42 | + |
| 43 | +This takes quite some time, because it restarts the device before each test, to make sure there's no leftover state from a previous test lingering. |
| 44 | + |
| 45 | +The following assumes you have the MicroPythonOS REPL shell show up when you run mpremote.py, meaning this works: |
| 46 | + |
| 47 | +``` |
| 48 | +./lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py ls |
| 49 | +``` |
| 50 | + |
| 51 | +Then you can run a specific unit test by adding the --ondevice option and providing its file as an argument: |
| 52 | + |
| 53 | +``` |
| 54 | +./tests/unittest.sh --ondevice tests/test_package_manager.py |
| 55 | +``` |
| 56 | + |
| 57 | +To run all unit tests, do: |
| 58 | + |
| 59 | +``` |
| 60 | +./tests/unittest.sh --ondevice # this takes a long time |
| 61 | +``` |
| 62 | + |
| 63 | + |
0 commit comments