-
Notifications
You must be signed in to change notification settings - Fork 178
Add documentation for unit testing #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2e9c131
add documentation for unit testing
lorjala 91127fb
update unit testing documentation for mbed cli
lorjala c59970d
move unit testing documentation for mbed cli to cli-test-debug.md
lorjala 922e351
Copy edit cli-test-debug.md
bac0962
Copy edit testing_intro.md
d9ee5c9
Copy edit unit_testing.md
90203d2
removed a link to a non-existing page
lorjala 63d9bbe
Merge branch 'development' into unittests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## Unit testing | ||
|
||
### Introduction | ||
|
||
Traditional software testing is defined into three main levels: unit testing, integration testing and system testing. These levels are often pictured as a pyramid to indicate the amount of testing for each level. | ||
|
||
``` | ||
^ Testing level | ||
| | ||
| /\ | ||
| / \ System testing | ||
| /----\ | ||
| / \ Integration testing | ||
| /--------\ | ||
| / \ Unit testing | ||
| /------------\ | ||
| | ||
*-------------------> Amount of tests | ||
``` | ||
|
||
We perform integration and system testing in an environment where we run the tests with the full Mbed OS. Other testing tools for Mbed OS require specific embedded hardware, which means traditional unit testing is not possible. | ||
|
||
Unit testing takes place in a build environment where we test each C or C++ class or module in isolation. This means we build test suites into separate test binaries and stub all access outside to remove dependencies on any specific embedded hardware or software combination. This allows us to complete the testing using native compilers on the build machine. | ||
|
||
### Using unit tests | ||
|
||
#### Test code structure | ||
|
||
Unit tests are located in Mbed OS repository under `UNITTESTS`. Each unit test uses an identical directory tree structure to the file to be tested. This makes it easier to find unit tests for a particular class or a module. For example, if the file to be tested is `rtos/Semaphore.cpp`, then all the test files are in the `UNITTESTS/rtos/Semaphore` directory. | ||
|
||
##### Test discovery | ||
|
||
Registering unit tests for running is automatic, and the test runner handles registration. However, test files are not automatically assigned to be built. We build unit tests by using a separate build system, which searches for unit tests under the `UNITTESTS` directory. | ||
|
||
For the build system to find and build any test suite automatically, a unit test configuration file named `unittest.cmake` is required to be included with each unit test. This configuration file contains a name for the test and other source files the build requires. | ||
|
||
##### Test names | ||
|
||
Each test suite requires a name to be configured in the `unittest.cmake` file. This name is used for generated files and when running a subset of tests. | ||
|
||
#### Building, running and writing tests | ||
|
||
Unit testing requires external tools you need to install. See the developer [documentation](https://github.com/ARMmbed/mbed-os/blob/master/UNITTESTS/README.md) in GitHub for the full installation guide. | ||
|
||
You can build and run unit tests through Arm Mbed CLI. You can also use the tool to generate new test files. For information on using Mbed CLI, please see the [CLI documentation](/docs/development/tools/arm-mbed-cli.html). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we've removed this page.