Skip to content

Commit 185879f

Browse files
committed
Add docs about new test macro
1 parent 4f6561f commit 185879f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/tools/testing/testing_greentea.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ You can run tests throughout Mbed OS and for your project's code. They are locat
1414

1515
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.
1616

17+
The macro `MBED_TEST_MODE` is defined when building tests with Mbed CLI versions 1.9.0 and later. You can wrap your application's `main()` function in a preprocessor check to prevent multiple `main()` functions from being defined:
18+
19+
```c++
20+
#if !MBED_TEST_MODE
21+
int main() {
22+
// Application code
23+
}
24+
#endif
25+
```
26+
1727
In addition to being placed under a `TESTS` directory, test sources must exist under two other directories: a test group directory and a test case directory. The following is an example of this structure:
1828

1929
```

0 commit comments

Comments
 (0)