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/testing_greentea.md
+26-25Lines changed: 26 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ This document will help you start using Greentea. Please see the [`htrun` docume
10
10
11
11
### Test code structure
12
12
13
-
You can run tests throughout Mbed OS and for your project's code. They are located under a special directory called `TESTS`.
13
+
Greentea tests can be created anywhere in the Mbed OS directory structure or in your project's code. They are located under a special directory called `TESTS`. By convention, greentea tests for a specific Mbed OS library should be placed in a `TESTS` folder under that library. The `mbed-os/TESTS` folder is dedicated to integration or system tests.
14
14
15
15
The fact that the code is located under this directory means that it is ignored when building applications and libraries. It is only used when building tests. This is important because all tests require a `main()` function, and building them with your application would cause multiple `main()` functions to be defined.
16
16
@@ -43,7 +43,7 @@ Test discovery also obeys the same rules that are used when building your projec
43
43
For example, if you place a test under the directory `FEATURE_BLE` with the following path:
This test case is only discovered if the target being tested supports the BLE feature. Otherwise, the test is ignored.
@@ -149,7 +149,8 @@ To interact with the host test from the device, you can use two functions: `gree
149
149
150
150
### Creating the host test
151
151
152
-
This example writes an integration test that sends `hello` to the host and waits until it receives `world`. Create a file called `hello_world_tests.py` in the `TESTS/host_tests` folder, and fill it with:
152
+
This example writes an integration test that sends `hello` to the host and waits until it receives `world`.
153
+
Create `host_tests` directory under `mbed-os/TESTS/`, if it does not exist and create a file called `hello_world_tests.py` in the `mbed-os/TESTS/host_tests` folder, and fill it with:
153
154
154
155
```py
155
156
from mbed_host_tests import BaseHostTest
@@ -189,7 +190,7 @@ This registers one function you can call from the device: `init`. The function c
189
190
190
191
### Creating the Greentea test
191
192
192
-
This example writes the embedded part of this test. Create a new file `main.cpp`in`TESTS/tests/integration-test`, and fill it with:
193
+
This example writes the embedded part of this test. Create a new file `main.cpp`under`TESTS/integration/test_case` directory, and fill it with:
@@ -288,22 +289,22 @@ The default action of Greentea using `mbed test` is to execute all tests found.
288
289
289
290
### Limiting tests
290
291
291
-
You can select test cases by name using the `-n` argument. This command executes all tests named `tests-mbedmicro-rtos-mbed-mail` from all builds in the test specification:
292
+
You can select test cases by name using the `-n` argument. This command executes all tests named `platform-tests-tests-mbed_platform-atomic` from all builds in the test specification:
292
293
293
294
```
294
-
$ mbed test -n tests-mbedmicro-rtos-mbed-mail
295
+
$ mbed test -n platform-tests-tests-mbed_platform-atomic
295
296
```
296
297
297
-
When using the `-n` argument, you can use the `*` character as a wildcard. This command executes all tests that start with `tests-` and have `-rtos-` in them.
298
+
When using the `-n` argument, you can use the `*` character as a wildcard. This command executes all tests that start with `tests-` and have `-mbed_platform-` in them.
298
299
299
300
```
300
-
$ mbed test -n tests-*-rtos-*
301
+
$ mbed test -n tests-*-mbed_platform-*
301
302
```
302
303
303
-
You can use a comma (`,`) to separate test names (argument `-n`) and build names (argument `-t`). This command executes the tests `tests-mbedmicro-rtos-mbed-mail` and `tests-mbed_drivers-c_strings` for the `K64F-ARM` and `K64F-GCC_ARM` builds in the test specification:
304
+
You can use a comma (`,`) to separate test names (argument `-n`) and build names (argument `-t`). This command executes the tests `platform-tests-tests-mbed_platform-atomic` and `drivers-tests-tests-mbed_drivers-c_strings` for the `K64F-ARM` and `K64F-GCC_ARM` builds in the test specification:
304
305
305
306
```
306
-
$ mbed test -n tests-mbedmicro-rtos-mbed-mail,tests-mbed_drivers-c_strings -t K64F-ARM,K64F-GCC_ARM
307
+
$ mbed test -n platform-tests-tests-mbed_platform-atomic,drivers-tests-tests-mbed_drivers-c_strings -t K64F-ARM,K64F-GCC_ARM
307
308
```
308
309
309
310
### Selecting platforms
@@ -393,19 +394,19 @@ Place this file in your root folder, and name it `test_spec.json`.
Copy file name to clipboardExpand all lines: docs/debugging-testing/testing/unit_testing.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,9 +61,9 @@ In a terminal window:
61
61
62
62
## Test code structure
63
63
64
-
Find unit tests in the Mbed OS repository under the `UNITTESTS` folder. 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 `unittest.cmake` file for test configuration.
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 `unittest.cmake` file for test configuration.
65
65
66
-
All the class stubs should be located in the `UNITTESTS/stubs` directory. Multiple test suites can use a single stub class, which should follow the naming convention `ClassName_stub.cpp` for the source file and `ClassName_stub.h` for the header file. Use the actual header files for the unit tests, and don't stub headers if possible. The stubbed headers reside in the `UNITTESTS/target_h` directory.
66
+
All the class stubs should be located in the Mbed OS root directory `UNITTESTS/stubs`. Multiple test suites can use a single stub class, which should follow the naming convention `ClassName_stub.cpp` for the source file and `ClassName_stub.h` for the header file. Use the actual header files for the unit tests, and don't stub headers if possible. The stubbed headers reside in the `UNITTESTS/target_h` directory.
67
67
68
68
### Test discovery
69
69
@@ -190,7 +190,7 @@ With the following steps, you can write a unit test. This example creates dummy
190
190
191
191
## Add here test classes and stubs
192
192
set(unittest-test-sources
193
-
example/MyClass/test_MyClass.cpp
193
+
${CMAKE_CURRENT_LIST_DIR}/test_MyClass.cpp
194
194
stubs/OtherClass_stub.cpp
195
195
)
196
196
```
@@ -227,7 +227,7 @@ With the following steps, you can write a unit test. This example creates dummy
227
227
}
228
228
```
229
229
230
-
1. Stub all external dependencies. Create the following stub in `UNITTESTS/stubs`:
230
+
1. Stub all external dependencies. Create the following stub in the Mbed OS root directory `UNITTESTS/stubs`:
0 commit comments