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
Copy file name to clipboardExpand all lines: docs/debugging-testing/testing/unit_testing.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Unit tests exercise code in small functional "units", such as a single function
8
8
9
9
## Prerequisites
10
10
11
-
Please install the following dependencies to use Mbed OS unit testing.
11
+
You will need to install the following dependencies to use Mbed OS unit testing:
12
12
13
13
- GNU toolchains.
14
14
- GCC 6 or later. We recommend you use MinGW-W64 on Windows, but any Windows port of the above GCC versions works.
@@ -72,19 +72,19 @@ In a terminal window:
72
72
73
73
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.
74
74
75
-
All the stub source files are built in a stub CMake library target (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.
75
+
All the stub source files are built in a stub CMake library target (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.
76
76
77
77
78
78
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 of an external source, not part of Mbed OS.
79
79
80
80
81
-
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` directory 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.
81
+
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` directory 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.
82
82
83
83
All the stub libraries and header libraries are defined under `UNITTESTS/stubs/` directory.
84
84
85
85
Libraries for fakes are under the `UNITTESTS/fakes` directory. These provide mock implementations that are meant to replace the stub version that does nothing. Usually, these will replace the header files as well as the source files and cannot be used together with their stub equivalents.
86
86
87
-
The upcoming [Example](#Example) section describes how to write a unit test for a dummy example class (Unit Under Test). The example walks you through creating a header library and a stub interface library using CMake.
87
+
The upcoming [Example](#Example) section describes how to write a unit test for a dummy example class (Unit Under Test). The example walks you through creating a header library and a stub interface library using CMake.
88
88
89
89
### Test discovery
90
90
@@ -131,13 +131,13 @@ With the following steps, you can write a unit test. This example creates dummy
131
131
#endif
132
132
```
133
133
134
-
1. Add a new `mbed-headers-example` interface library:
134
+
1. Add a new `mbed-headers-example` interface library:
135
135
136
136
**mbed-os/stubs/CMakeLists.txt**
137
-
137
+
138
138
```
139
139
add_library(mbed-headers-example INTERFACE)
140
-
140
+
141
141
target_include_directories(mbed-headers-example
142
142
INTERFACE
143
143
${mbed-os_SOURCE_DIR}/example
@@ -179,35 +179,35 @@ With the following steps, you can write a unit test. This example creates dummy
179
179
180
180
181
181
1. Create an example stub directory in `mbed-os/UNITTESTS/stubs/example`.
182
-
1. Create the following example interface api stub source in `mbed-os/UNITTESTS/stubs/example`
182
+
1. Create the following example interface api stub source in `mbed-os/UNITTESTS/stubs/example`
Copy file name to clipboardExpand all lines: docs/introduction/introduction.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ Our [quick start](../quick-start/index.html) guides show how to build an example
24
24
25
25
## Recently updated documentation
26
26
27
+
- We've updated the [Unit testing](../debug-test/unit-testing.html) information to reflect changes to the version of CMake used. You will need to update to CMake version 3.19 or above and alter your test code structure.
27
28
- A new [tutorial about link time optimization](../apis/link-time-optimization.html).
28
29
- A new [PSA porting guide](../porting/porting-security.html).
29
30
- New information about [API life cycle ](../introduction/versions-and-releases.html#the-api-life-cycle) and how to [contribute experimental APIs](../contributing/software-design.html#experimental-apis) and [use them in an application](../program-setup/build-rules.html#label-directories).
0 commit comments