- Install Windows Subsystem for Linux and Ubuntu
- Open Windows Control Panel (Windows Key and type 'Control Panel')
- Click on 'Programs'
- Click on 'Turn Windows features on or off'
- Scroll down and enable 'Windows Subsystem for Linux'
- Goto the Windows Store and search 'Ubuntu 18.04 LTS'
- Open Windows Subsystem for Linux (tested with Ubuntu 18.04)
- Change directories to where you'd like to store the cpputest repo. Ideally keep this at the same level as the code to be tested.
- Clone cppUtest (git clone https://github.com/cpputest/cpputest.git)
- Update all packages 'sudo apt-get update'
- Install gcc toolchain, autoconf and build tools
sudo apt-get install build-essential autoconf automake libtool g++
You can make cpputest in many ways, here are two potential methods from within WSL (I've had the most success with Cmake).
- Change directory to cpputest_build
- Make with cmake
cmake .. - Run make with
make - Install with
sudo make install
- Change to the cpputest director
cd /mnt/"directory to cppUtest"/cpputest/ - Run autoreconf script './autoreconf.sh"
- Change directory to cpputest_build
- Configure the build
../configure make checkmake tddsudo make install
- From within WSL, add CPPUTEST_HOME to profile, example:
- Use vim to edit
vim ~/.profile - Append line
export CPPUTEST_HOME=/mnt/"directory to cppUtest"/cpputest - Save file (Esc, x)
- Use vim to edit
- Copy the library folder from make install, to CPPUTEST_HOME:
cp -a /usr/local/lib $CPPUTEST_HOME - From cmd or Powershell, set the WSL default user
ubuntu config --default-user username(https://docs.microsoft.com/en-us/windows/wsl/user-support)
The Cpputest makefile resides in the local directory and is configured based on the project under test. As an example, use the makefile from James Grenning: https://github.com/jwgrenning/cpputest-starter-project.
- Add source files and/or directories of test files (SRC_FILES += and/or SRC_DIRS +=).
- Add test files and/or directories of test files (TEST_SRC_FILES += and/or TEST_SRC_DIRS +=).
- Add directory of Mocks, stubs, and fakes (MOCS_SCR_DIRS +=)
- Eable CppUMock: CPPUTEST_USE_EXTENSIONS = Y
- Add source include directory (INCLUDE_DIRS +=)
- Adjust the CppuTest objs directory as needed
- Adjust the compiler flags
- Add additional libraries as needed (LD_LIBRARIES += -lgcov for coverage report)
- Enable coverage reporting: CPPUTEST_USE_GCOV = Y
- Add project specific defines as needed (example: CPPUTEST_CFLAGS += -DSTEM32F429xx)
- From WSL:
make clean, thenmake gcov - Windows cmd/Powershell:
bash --login -c "make clean", thenbash --login -c "make gcov"("--login" is needed to take advantage of the CPPUTEST_HOME path variable.)
Note: make gcov is used to make with coverage report, use make all if coverage report is not desired.
In essence, runs the same commands from the Windows cmd/Powershell manual steps. See cpputest_runner.bat
- Forked from James Grenning: https://github.com/jwgrenning/cpputest-starter-project
- A cpputest starter project
- See the readme directory: cpputest-starter-kit-readme.pdf or cpputest-starter-kit-readme.rtf
- https://github.com/miguelmoraperea/guide_setup_cpputest_eclipse_win_7