![]() ![]() 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.Īll the stub libraries and header libraries are defined under UNITTESTS/stubs/ directory. ![]() All CMake libraries containing header files are linked with mbed-headers. ![]() Stubbed header files reside in the UNITTESTS/target_h directory and are built with the mbed-headers-base CMake library. Alternatively, create a stub library if _stub is an implementation of an external source, not part of Mbed OS.Īll the Mbed OS header files are built with CMake INTERFACE libraries (e.g., mbed-headers-platform). They should be built as part of their respective stub CMake library. ![]() The new stub file should follow the naming convention _stub.cpp for the source file and _stub.h for the header file. 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. Each test suite needs to have its own CMakeLists.txt file for test CMake configuration.Īll 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. 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. This makes it easier to find unit tests for a particular class or a module. We recommend that unit test files use an identical directory path as the file under test. Unit tests are located in the tests/UNITTESTS subdirectory of each library. Add MinGW, CMake and Python into system PATH.Download Python 2.7 or Python 3 from, and run the installer.Download CMake binaries from, and run the installer.Download and install MinGW-W64 from SourceForge.Install the GNU Compiler collection if required: brew install gcc Install the additional Python package gcovr for code coverage report: pip install "gcovr>=4.1" Install Python and Pip: brew install python Install Xcode command-line tools with xcode-select -install. Install the additional Python package gcovr for code coverage report:.Sudo apt-get -y install python python-setuptools & sudo apt-get install python-pip Install Python and its package manager:.Sudo apt-get -y install build-essential cmake Install the compilation packages to the host:.Installing dependencies on Debian or Ubuntu We recommend you use MinGW-W64 on Windows, but any Windows port of the above GCC versions works.ĭetailed instructions for supported operating systems are below. You will need to install the following dependencies to use Mbed OS unit testing: Mbed OS provides mock and stub implementations of the Mbed OS components to make unit testing easier. Unit tests are quick to run and provide targeted testing of your code during development. To achieve this, unit tests make extensive use of "stubs", "mocks" and "fakes" to isolate the code under test from any external dependencies. The unit tests are designed to be run on your host development machine and should not have any dependency on the underlying platform or external libraries. Unit tests exercise code in small functional "units", such as a single function or a class. To prevent and solve problems, please see the troubleshooting section. This document describes how to write and test unit tests for Mbed OS. ![]()
0 Comments
Leave a Reply. |