Skip to content

Commit 75916c2

Browse files
Apply suggestions from code review
Co-authored-by: Paul Szczepanek <[email protected]>
1 parent edb4d40 commit 75916c2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/debugging-testing/testing/unit_testing.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ In a terminal window:
6161

6262
## Test code structure
6363

64-
Find unit tests in the Mbed OS repository under the `UNITTESTS` folder 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.
64+
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.
6565

6666
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` depending on the test case.
6767

@@ -71,6 +71,8 @@ All the Mbed OS header files are built with CMake `INTERFACE` libraries (e.g`mbe
7171

7272
All the stub libraries and header libraries are defined under `UNITTESTS/stubs/` directory.
7373

74+
Libraries for fakes are under `UNITTESTS/stubs/` directory. These provide mock implementations that are meant to replace the stub version that do nothing. Usually these will replace the header files as well as the source files and cannot be used together with their stub equivalents.
75+
7476
### Test discovery
7577

7678
Registering unit tests to run happens automatically, and the test runner handles registration. However, test suites do not automatically build.
@@ -153,7 +155,7 @@ With the following steps, you can write a unit test. This example creates dummy
153155
}
154156
```
155157
156-
1. Create a directory for MyClass unit tests in `mbed-os/example/tests/unittests/MyClass`.
158+
1. Create a directory for MyClass unit tests in `mbed-os/example/tests/UNITTESTS/MyClass`.
157159
1. Create a source and CMake configuration file for MyClass unit tests in `mbed-os/example/tests/unittests/MyClass`:
158160
159161
**test_MyClass.cpp**

0 commit comments

Comments
 (0)