2019-12-23 13:35:06 +00:00
|
|
|
# Unit tests
|
|
|
|
|
|
|
|
Unit tests test some smaller individual parts of code (mainly functions and classes) and are run by micropython directly.
|
|
|
|
|
2022-02-25 12:03:18 +00:00
|
|
|
## How to run them
|
|
|
|
|
|
|
|
Run all tests:
|
|
|
|
```sh
|
|
|
|
make test
|
|
|
|
```
|
|
|
|
|
|
|
|
Run a specific test file:
|
|
|
|
```sh
|
|
|
|
make test TESTOPTS=test_apps.bitcoin.signtx.py
|
|
|
|
```
|
|
|
|
|
|
|
|
__WARNING__: unittests cannot run with frozen emulator, use `make build_unix` to create non-frozen emulator.
|
|
|
|
|
2019-12-23 13:35:06 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
Please use the unittest.TestCase class:
|
|
|
|
|
|
|
|
```python
|
|
|
|
from common import *
|
|
|
|
|
|
|
|
class TestSomething(unittest.TestCase):
|
|
|
|
|
|
|
|
test_something(self):
|
|
|
|
self.assertTrue(True)
|
|
|
|
```
|
|
|
|
|
2020-11-11 13:43:09 +00:00
|
|
|
Usage of `assert` is discouraged because it is not evaluated in production code (when `PYOPT=1`). Use `self.assertXY` instead, see `unittest.py`.
|