Skip to content

Commit aa4793e

Browse files
committed
update README.md with more unit testing examples
1 parent 2e50353 commit aa4793e

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ As shown above, tests exist inside `TESTS\testgroup\testcase\` directories. Plea
730730

731731
## Unit testing
732732

733-
Use the `mbed unittest` command to build and run unit tests, and to generate files for new unit tests.
733+
Use the `mbed unittest` command to build and run unit tests, or to generate files for new unit tests.
734734

735735
Build and run unit tests with `mbed unittest`. The arguments are:
736736

@@ -747,6 +747,46 @@ Build and run unit tests with `mbed unittest`. The arguments are:
747747

748748
Generate files for a new unit test with `mbed unittest --new <FILE>`.
749749

750+
### Building and running unit tests
751+
752+
You can specify to only **build** the unit tests by using the `--skip-run` option:
753+
754+
```
755+
$ mbed unittest --skip-run
756+
```
757+
758+
You can specify to only **run** the unit tests by using the `--skip-build` option:
759+
760+
```
761+
$ mbed unittest --skip-build
762+
```
763+
764+
If you do not specify any of these, `mbed unittest` will build all available unit tests and run them.
765+
766+
### Running a subset of tests
767+
768+
You can run a **limited set** of unit tests by using the `-r` or `--regex` option. This takes a regular expression, which it compares against the test names. For example to run all cellular unit tests you can specify:
769+
770+
```
771+
$ mbed unittest -r cellular
772+
```
773+
774+
### Getting code coverage
775+
776+
You can generate a code coverage report by using the `--coverage` option. For example to create an html report you can specify:
777+
778+
```
779+
$ mbed unittest --coverage html
780+
```
781+
782+
### Creating new unit tests
783+
784+
All unit tests are under `mbed-os/UNITTESTS` directory. You can **generate** the necessary files for a unit test by using the `--new` option. For example to create the files for `rtos/Semaphore.cpp` you can specify:
785+
786+
```
787+
$ mbed unittest --new rtos/Semaphore.cpp
788+
```
789+
750790
## Publishing your changes
751791

752792
### Checking status

0 commit comments

Comments
 (0)