You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Install the addition Python package `gcovr` for code coverage report:
42
+
``
43
+
pip install "gcovr>=4.1"
44
+
``
33
45
34
46
### Installing dependencies on macOS
35
47
@@ -45,7 +57,10 @@ In a terminal window:
45
57
sudo easy_install pip
46
58
```
47
59
48
-
1. Install Gcovr `pip install "gcovr>=4.1"`.
60
+
1. Install the addition Python package `gcovr` for code coverage report:
61
+
``
62
+
pip install "gcovr>=4.1"
63
+
``
49
64
1. (Optional) Install GCC with `brew install gcc`.
50
65
51
66
### Installing dependencies on Windows
@@ -56,15 +71,18 @@ In a terminal window:
56
71
1. Download CMake binaries from https://cmake.org/download/, and run the installer.
57
72
1. Download Python 2.7 or Python 3 from https://www.python.org/getit/, and run the installer.
58
73
1. Add MinGW, CMake and Python into system PATH.
59
-
1. Install Gcovr `pip install "gcovr>=4.1"`.
74
+
1. Install the addition Python package `gcovr` for code coverage report:
75
+
``
76
+
pip install "gcovr>=4.1"
77
+
``
60
78
61
79
## Test code structure
62
80
63
-
Unit tests in the Mbed OS repository are located in the `UNITTESTS`directory of each library. We recommend unit test files use an identical directory path as the file under test. This makes it easier to find unit tests for a particular class or a module. For example, if the file you're testing is `some/example/path/ClassName.cpp`, then all the test files are in the `UNITTESTS/some/example/path/ClassName` directory. Each test suite needs to have its own `CMakeLists.txt` file for test CMake configuration.
81
+
Unit tests are located in the `tests/UNITTESTS`subdirectory of each library. We recommend that unit test files use an identical directory path as the file under test. This makes it easier to find unit tests for a particular class or a module. For example, if the file you are testing is `some/example/path/ClassName.cpp`, then all the test files are in the `UNITTESTS/some/example/path/ClassName` directory. Each test suite needs to have its own `CMakeLists.txt` file for test CMake configuration.
64
82
65
-
All the stub sources are built in stub CMake library targets (e.g `mbed-stubs-rtos`) and linked to the `mbed-stubs` CMake target. The CMake target of the library unit under test is expected to link with the required stub libraries or `mbed-stubs` in case of requiring multiple stub libraries.
83
+
All the stub source files are built in a stub CMake library targets (e.g `mbed-stubs-rtos`) and linked to the `mbed-stubs` CMake target. The CMake target of the library unit under test is expected to link with the required stub libraries or `mbed-stubs`if it requires multiple stub libraries.
66
84
67
-
The new stub file should follow the naming convention `ClassName_stub.cpp` for the source file and `ClassName_stub.h` for the header file. They should be added under their respective existing stub CMake library or create their stub library in case of this `ClassName_stub` providing an implementation for an external source that is not part of the Mbed OS source.
85
+
The new stub file should follow the naming convention `<CLASS_NAME>_stub.cpp` for the source file and `<CLASS_NAME>_stub.h` for the header file. They should be built as part of their respective stub CMake library. Alternatively, create a stub library if `<CLASS_NAME>_stub` is an implementation for an external source not part of the Mbed OS.
68
86
69
87
All the Mbed OS header files are built with CMake `INTERFACE` libraries (e.g`mbed-headers-platform`). Stubbed header files reside in the `UNITTESTS/target_h` and are built with the `mbed-headers-base` CMake library. All CMake libraries containing header files are linked with `mbed-headers`. The CMake target of the library unit under test is expected to link with the required header file libraries or `mbed-headers` in case of requiring multiple header libraries.
70
88
@@ -220,15 +238,15 @@ This example does not use any Mbed OS code. If your unit tests do, remember to u
220
238
221
239
#### Mbed CLI 2
222
240
223
-
- Mbed CLI 2 is not supporting the `mbed test --unittests` command, please use CMake and a Make command directly.
241
+
- Mbed CLI 2 does not currently support the `mbed test --unittests` command, please use CMake and a Make command directly.
224
242
225
243
#### Build tests directly with CMake
226
244
227
245
1. Create a build directory: `mkdir UNITTESTS/build`.
228
246
1. Move to the build directory: `cd UNITTESTS/build`.
229
247
1. Run CMake using a relative path to the `UNITTESTS` folder as the argument. So from `UNITTESTS/build` use `cmake ..-DMBED_BUILD_UNITTESTS=ON`:
230
248
- Add `-g [generator]` if generating files other than Unix Makefiles. For example, for MinGW, use `-g "MinGW Makefiles"`.
231
-
- Add `-DCMAKE_MAKE_PROGRAM=<value>`, `-DCMAKE_CXX_COMPILER=<value>` and `-DCMAKE_C_COMPILER=<value>` to use a specific Make programand compilers.
249
+
- Add `-DCMAKE_MAKE_PROGRAM=<value>`, `-DCMAKE_CXX_COMPILER=<value>` and `-DCMAKE_C_COMPILER=<value>` to use a specific Make program and compilers.
232
250
- Add `-DCMAKE_BUILD_TYPE=Debug` for a debug build.
233
251
- Add `-DCOVERAGE=True` to add coverage compiler flags.
234
252
- Add `-Dgtest_disable_pthreads=ON` to run in a single thread.
0 commit comments