\r
This is a framework for doing unit testing with CMake. \r
\r
-Content\r
-* [Setup steps for Windows](#setup)\r
-* [Usage](#usage)\r
-* [Demo](#demo)\r
+[TOC]\r
\r
-<a name="setup"></a>\r
## Setup steps for Windows \r
* Install Visual Studio 2008\r
* Install CMake \r
* Easy to swap between compilers since it is build automatically\r
* No installation of testing framework is required beforehand\r
\r
-<a name="usage"></a>\r
## Usage \r
To setup testing you need to define a "unit" of code that shall be tested and a corresponding "unittest".\r
\r
$ add_unittest(TARGET folder2_test\r
$ SRCS folder2_test.cpp\r
$ INCS .\r
- $ DEPS folder2)\r
-\r
-<a name="demo"></a>\r
-## Demo\r
- $ mkdir build\r
- $ cd build\r
- $ cmake -GNinja ..\r
- $ -- The C compiler identification is GNU 6.2.0\r
- $ -- The CXX compiler identification is GNU 6.2.0\r
- $ -- Check for working C compiler: C:/programs/msys64/mingw64/bin/cc.exe\r
- $ -- Check for working C compiler: C:/programs/msys64/mingw64/bin/cc.exe -- works\r
- $ -- Detecting C compiler ABI info\r
- $ -- Detecting C compiler ABI info - done\r
- $ -- Detecting C compile features\r
- $ -- Detecting C compile features - done\r
- $ -- Check for working CXX compiler: C:/programs/msys64/mingw64/bin/c++.exe\r
- $ -- Check for working CXX compiler: C:/programs/msys64/mingw64/bin/c++.exe -- works\r
- $ -- Detecting CXX compiler ABI info\r
- $ -- Detecting CXX compiler ABI info - done\r
- $ -- Detecting CXX compile features\r
- $ -- Detecting CXX compile features - done\r
- $ -- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)\r
- $ -- Found Git: C:/programs/msys64/usr/bin/git.exe (found version "2.9.0")\r
- $ -- Configuring done\r
- $ -- Generating done\r
- $ -- Build files have been written to: C:/Projects/repos/jannikz/unittest_cmake/build/googletest-download\r
- $ [1/9] Creating directories for 'googletest'\r
- $ [2/9] Performing download step (git clone) for 'googletest'\r
- $ Cloning into 'googletest-src'...\r
- $ Already on 'master'\r
- $ Your branch is up-to-date with 'origin/master'.\r
- $ [3/9] No patch step for 'googletest'\r
- $ [4/9] Performing update step for 'googletest'\r
- $ Current branch master is up to date.\r
- $ [5/9] No configure step for 'googletest'\r
- $ [6/9] No build step for 'googletest'\r
- $ [7/9] No install step for 'googletest'\r
- $ [8/9] No test step for 'googletest'\r
- $ [9/9] Completed 'googletest'\r
- $ -- Found PythonInterp: C:/programs/msys64/mingw64/bin/python.exe (found version "2.7.11")\r
- $ ===================================================\r
- $ Component:\r
- $ folder1:\r
- $ Sources:\r
- $ - folder1.c\r
- $ Includes:\r
- $ - .\r
- $ Dependencies:\r
- $ Definitions:\r
- $ ===================================================\r
- $ Component:\r
- $ folder1_if:\r
- $ Sources:\r
- $ Includes:\r
- $ - .\r
- $ Dependencies:\r
- $ Definitions:\r
- $ ===================================================\r
- $ UnitTest:\r
- $ folder1_test:\r
- $ Sources:\r
- $ - folder1_test.cpp\r
- $ Includes:\r
- $ - .\r
- $ Dependencies:\r
- $ - folder1\r
- $ Definitions:\r
- $ ===================================================\r
- $ Component:\r
- $ folder2:\r
- $ Sources:\r
- $ - folder2.c\r
- $ Includes:\r
- $ - .\r
- $ Dependencies:\r
- $ - folder1\r
- $ Definitions:\r
- $ ===================================================\r
- $ UnitTest:\r
- $ folder2_test:\r
- $ Sources:\r
- $ - folder2_test.cpp\r
- $ Includes:\r
- $ - .\r
- $ Dependencies:\r
- $ - folder2\r
- $ Definitions:\r
- $ ===================================================\r
- $ -- Configuring done\r
- $ -- Generating done\r
- $ -- Build files have been written to: C:/Projects/repos/jannikz/unittest_cmake/build\r
- $ cmake --build .\r
- $ [1/19] Building C object folder1/Source/CMakeFiles/folder1.dir/folder1.c.obj\r
- $ [2/19] Linking C static library folder1\Source\libfolder1.a\r
- $ [3/19] Building C object folder2/Source/CMakeFiles/folder2.dir/folder2.c.obj\r
- $ [4/19] Linking C static library folder2\Source\libfolder2.a\r
- $ [5/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.obj\r
- $ [6/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.obj\r
- $ [7/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.obj\r
- $ [8/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock.dir/__/googletest/src/gtest-all.cc.obj\r
- $ [9/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock_main.dir/__/googletest/src/gtest-all.cc.obj\r
- $ [10/19] Building CXX object googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj\r
- $ [11/19] Linking CXX static library googletest-build\googlemock\gtest\libgtest.a\r
- $ [12/19] Linking CXX static library googletest-build\googlemock\libgmock.a\r
- $ [13/19] Linking CXX static library googletest-build\googlemock\libgmock_main.a\r
- $ [14/19] Building CXX object googletest-build/googlemock/gtest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj\r
- $ [15/19] Linking CXX static library googletest-build\googlemock\gtest\libgtest_main.a\r
- $ [16/19] Building CXX object folder2/Test/CMakeFiles/folder2_test.dir/folder2_test.cpp.obj\r
- $ [17/19] Building CXX object folder1/Test/CMakeFiles/folder1_test.dir/folder1_test.cpp.obj\r
- $ [18/19] Linking CXX executable folder2\Test\folder2_test.exe\r
- $ Running main() from gtest_main.cc\r
- $ [==========] Running 1 test from 1 test case.\r
- $ [----------] Global test environment set-up.\r
- $ [----------] 1 test from function3_test\r
- $ [ RUN ] function3_test.compare3\r
- $ [ OK ] function3_test.compare3 (0 ms)\r
- $ [----------] 1 test from function3_test (0 ms total)\r
- $ \r
- $ [----------] Global test environment tear-down\r
- $ [==========] 1 test from 1 test case ran. (0 ms total)\r
- $ [ PASSED ] 1 test.\r
- $ [19/19] Linking CXX executable folder1\Test\folder1_test.exe\r
- $ Running main() from gtest_main.cc\r
- $ [==========] Running 2 tests from 2 test cases.\r
- $ [----------] Global test environment set-up.\r
- $ [----------] 1 test from function1_test\r
- $ [ RUN ] function1_test.compare1\r
- $ [ OK ] function1_test.compare1 (0 ms)\r
- $ [----------] 1 test from function1_test (0 ms total)\r
- $ \r
- $ [----------] 1 test from function2_test\r
- $ [ RUN ] function2_test.compare2\r
- $ [ OK ] function2_test.compare2 (0 ms)\r
- $ [----------] 1 test from function2_test (0 ms total)\r
- $ \r
- $ [----------] Global test environment tear-down\r
- $ [==========] 2 tests from 2 test cases ran. (0 ms total)\r
- $ [ PASSED ] 2 tests.\r
- \r
-\r
+ $ DEPS folder2)
\ No newline at end of file