Настройка рабочей среды
Установка библиотеки GTest в Ubuntu Linux
Для установки GTest в Ubuntu достаточно выполнить команду
sudo apt install libgtest-dev
Установка библиотеки GTest в Windows 10
Для установки библиотеки GTest в Windows 10 скачаем ее исходный код, скомпилируем с помощью CMake и подключим собранную библиотеку и заголовочные файлы к MinGW.
Убедитесь в том, что в системе установлены MinGW и CMake.
Скачайте zip архив со страницы релиза (версия 1.11.0 на момент написания текста). Ссылка находится в самом низу страницы.
Распакуйте архив и перейдите в директорию, содержащую файл CMakeLists.txt
. Выполняем сборку с помощью следующих команд (используйте интерфейс PowerShell):
> mkdir build; # создаем директорию для сборки > cd build; # переходим в директорию build > cmake -G "MinGW Makefiles" .. # генерируем файлы для сборки > cmake --build . # запускаем сборку
Подключаем библиотеку к MinGW:
- Скопируйте директорию
googletest/include/gtest
, в директорию MinGW, которая у автора этого текста выглядит такmingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/
. - Скопируйте содержимое директории
build/lib
(четыре файла с расширением.a
) в директорию MinGWmingw32/lib/
.
Готово. Теперь Вы можете подключать библиотеку GTest к своим проектам.
install googletest on Linux and Windows
This file contains 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
#!/bin/sh | |
# c.f.: https://qiita.com/y-vectorfield/items/6238cfd2d9c34aefe364 | |
# Modified library files installation directory | |
# move to working directory | |
cd ~/ | |
# download | |
git clone https://github.com/google/googletest.git | |
# build | |
cd googletest | |
mkdir build | |
cd build | |
cmake .. | |
make | |
# install | |
sudo cp -r ~/googletest/googlemock/include/gmock /usr/local/include/gmock | |
sudo cp -r ~/googletest/googletest/include/gtest /usr/local/include/gtest | |
sudo mkdir /usr/local/lib/gtest; sudo cp -r ~/googletest/build/lib/libgtest*.a /usr/local/lib/gtest/ | |
sudo mkdir /usr/local/lib/gmock; sudo cp -r ~/googletest/build/lib/libgmock*.a /usr/local/lib/gmock/ |
Setup GoogleTest on Windows
1. Setup build tools
You can skip some of the following steps if you have already installed them.
- Install Mingw-w64
- Install Python3
- Install GNU Make (Make for Windows GnuWin32 is sufficient)
- Install CMake
2. Build GoogleTest
-
Download GoogleTest release package, extract it, and go to folder:
googletest-release-x.x.x
-
Run following commands
cmake -G "MinGW Makefiles" make
3. Copy header and library files to your environment
You may have to change Mingw-w64 path in the following instructions, according to your environment.
- Copy 2 folders
googletest-release-x.x.x/googletest/include/gtest
andgoogletest-release-x.x.x/googletest/include/gmock
toC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/include/
- Copy gtest library files
copy googletest-release-x.x.x/lib/libgtest*.a
toC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gtest/
- Copy gmock library files
googletest-release-x.x.x/lib/libgmock*.a
toC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gmock/
4. Usage
MathLib will help you know how to use GoogleTest.
Время на прочтение
2 мин
Количество просмотров 69K
Google Test — это фреймворк от Google для юнит-тестирования кода на С++. Общей архитектурой он слегка напоминает общепринятые boost::test и CppUnit, хотя слегка отличается в деталях (как по мне — в лучшую сторону). Большая обзорная статья этого фреймворка уже как-то пробегала на Хабре, но нынче она в каком-то побитом состоянии (код не отображается), да и кажется мне слишком сложной для начала работы. Поэтому я коротко опишу «Hello world» на Google Test, указав на несколько потенциальных проблем, с которыми вы можете столкнуться, используя Google Test при разработке под Visual Studio.
Сборка
- Загружаем архив с кодом, разархивируем.
- В папке gtest-1.6.0\msvc есть два файла: gtest.sln и gtest-md.sln. Это файлы решений (Solution) Visual Studio. Отличаются они опциями сборки: gtest.sln собирает код с ключем /MT, а gtest-md.sln с ключем /MD. Если вы не знаете, за что отвечают эти ключи — можете почитать, к примеру, тут или тут. Вы должны скомпилировать тот же вариант, с которыми собирается проект, который вы собираетесь тестировать. Это важно, иначе получите кучу невразумительных ошибок линкера. Проверить, с какими ключами собирается ваш проект можно вот тут:
Код Google Test успешно собирается Visual Studio 2008\2010 (другими не пробовал). На выходе вы получите файлы gtestd.lib\gtest.lib (для дебаг и релиз конфигураций). Со сборкой на этом всё.
Hello world
- Открываем Solution, который вы собираетесь тестировать. Добавляем в него новый проект (консольное С++ приложение).
- В этот проект добавляем зависимость от скомпиленных на втором шаге библиотек gtestd.lib\gtest.lib, путь к include-папке Google Test, зависимости к тем проектам в вашем решении, которые вы собираетесь тестировать.
- Пишем в главном файле тестового проекта следующий код:
#include "stdafx.h" #include "gtest/gtest.h" class CRectTest : public ::testing::Test { }; TEST_F(CRectTest, CheckPerimeter) { CSomeRect rect; rect.x = 5; rect.y = 6; ASSERT_TRUE(rect.GetPerimeter() == 22); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
Здесь мы тестируем некий класс прямоугольника на правильность вычисления периметра. Вы заметили, как удобненько — не нужно ни регистрировать каждый тест в main-функции, ни даже писать объявления тестовых методов в заголовочных файлах.
- Запускаем тестовый проект. Видим следующее:
Грабли
Номер один
Не ошибитесь с выбором компилируемого решения на втором шаге. Если ошибетесь и забудете — выяснить в чём ошибка позже будет фактически не реально.
Номер два
Если вы планируете разнести основное тестовое приложение и сами тесты по разным проектам, вы столкнётесь с одной хитрой проблемой. Дело в том, что гугловские юнит-тесы по сути являются статическими классами и компилятор Visual C++ из-за имеющегося нём бага попросту выкинет эти классы по ходу компиляции. Для избежания этого бага нужно выкрутиться способом, описанным вот тут.
Номер три
Не забывайте, что тестируемые статические библиотеки нужно не достаточно добавить в зависимости (Dependencies) тестового проекта, их нужно добавить в ссылки (References), иначе получим ошибки линковки.
Дополнительные материалы
Чуть более глубокая статья на Хабре
Быстрый старт в родной документации
Часто задаваемые вопросы
Продвинутое использование фреймворка
Плагин к Visual Studio для запуска тестов
Успехов в тестировании.
С Новым Годом!
My need is simple. I have to compile and use googletest on windows using MinGW with msys. Has anyone some experience doing this?
Thanks for answers.
asked Mar 9, 2011 at 15:45
2
It took me some time but I figured it out. Here is the guide for anyone who face the same problem.
To be able to compile GoogleTest on Windows follow this instructions:
-
I assume you have MinGW with MSYS istalled.
-
Download and install CMake from the official site http://www.cmake.org/. Use the Win32 installer
version. Once you have completed the installation process copy executable files from
«xxx/CMake/bin» to «xxx/MinWG/bin». -
Download and install Python from http://www.python.org/. Again, the Windows installer does the job
fine.
Once you have completed the installation process copy the «python.exe»
form python folder to
«xxx/MinWG/bin». -
Download the latest stable GoogleTest from http://code.google.com/p/googletest/ and unpack it into some folder.
-
Run MSYS terminal and execute following commands.
cd xxx/gtest-x.x.x cmake -G "MSYS Makefiles" make
-
If you have compilation errors from pthread follow these instructions.
-
Copy the include folder «xxx/gtest-x.x.x/include» into your MinGW gcc include.
Copy the library files «xxx/gtest-x.x.x/*.a» into your MinGW gcc lib. -
When you compile tests add «-lgtest» parameter to gcc.
EDIT
Commentators are right. The coping of executables worked for me but generaly it is not a good practice. Try to use a symbolic link instead.
j0k
22.6k28 gold badges79 silver badges90 bronze badges
answered Mar 12, 2011 at 12:37
Rusty HorseRusty Horse
2,3887 gold badges26 silver badges38 bronze badges
3
To build libgtest.a without cmake/python, but only using mingw make, gtest now has a ‘make’ folder with a plain old makefile in it.
- Make sure, mingw\bin is in the path (try running ‘g++’ or something).
- Enter the gtest ‘googletest\make’ folder and run ‘make’.
- To test, run ‘sample1_unittest’ (gtest sample test output should appear).
- To generate the library ‘libgtest.a’, run ‘ar -rv libgtest.a gtest-all.o’
The library created is a full static library with no dll’s generated.
That should be all.
By the way, this also works for building googlemock, just enter the googlemock folder instead of googletest, and follow the same procedure.
answered Oct 18, 2016 at 15:15
2
The question was asked in 2011 and answer with most votes is also answered the same year. So, a fresh answer would improve the question effectiveness.
Tools You need & I tested with:
Mingw64 8.0.2
GoogleTest GitHUb Source Code repo branch 1.10.0
CMake 3.20.4
and Windows10
Steps
-
Install the mingw64 by double clicking and chose the path which does
not have space between directory names e.g. «Program Files» -
Open settings of the windows and then search environment variables
and oepn the dialog box to edit the Path environment variable -
Add the mingw64/bin directory name in the Windows Path Environment
variable e.g. C:\Users[USERNAME]\mingw64\bin (replace [USERNAME]
with your username e.g. Michael or Lee etc) -
Install CMake. It is double click install procedure. Make sure, its
bin directory path is added in the Path Environment Variable.
It would be installed in C:/Program Files/… -
Download GoogleTest repo extract it and create a build directory
inside the extracted directory. -
Execute the following commands
$ cd build
$ cmake .. -G «MinGW Makefiles»
$ mingw32-make.exe
-
Copy the four static libraries(*.a) from build directory
[ex: C:\Users[USERNAME]\sourcecodes\googletest-master\build\lib]
into lib of MingW64
[ex: C:\Users[USERNAME]\mingw64\x86_64-w64-mingw32\lib]
- Go to the GoogleTest extracted repo, navigate to
[ex
C:\Users[USERNAME]\sourcecodes\googletest-master\googletest\include\gtest]
Copy that whole gtest directory and copy to the folder
C:\Users[USERNAME]\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include
You are done to go. You can build and link Googltest with your C++ project. I also paste a CMakelists.txt sample
cmake_minimum_required(VERSION 3.12)
project(ProjectName VERSION 1.0.0 LANGUAGES CXX)
include_directories(include)
set(SOURCES src/library.cpp include/library.h)
add_executable(libabc ${SOURCES})
#############
## Testing ##
#############
enable_testing()
find_library(GTest gtest)
add_executable (unitTest test/unit_test.cpp)
target_link_libraries (unitTest gtest gtest_main)
add_test(AllFactTest unitTest)
I hope it would work.
answered Jun 23, 2021 at 19:55
TonyParkerTonyParker
2,0545 gold badges18 silver badges27 bronze badges
1
From the README of https://github.com/google/googletest/tree/master/googletest
:
When building Google Test as a standalone project, the typical workflow starts
with:
mkdir mybuild # Create a directory to hold the build output.
cd mybuild
cmake ${GTEST_DIR} # Generate native build scripts.
If you want to build Google Test’s samples, you should replace the last command
with
cmake -Dgtest_build_samples=ON ${GTEST_DIR}
answered Jan 9, 2021 at 9:52
As alternative it is also possible to build googletest using the usual MSYS/Mingw make.
So here is my alternative way:
-
Make sure MSys/MingW is installed on your Windows and the PATH environment is set to it
-
Open a cmd window — you can set the PATH explicitly here as well
-
CD to the unzipped googletest directory
-
Call configure with sh (part of MSys):
sh configure
-
Call
make
->libgtest.a
should be built. It is placed in your googletest-directorylib/.libs
subdirectory -
See README of googletest of how to integrate the
libgtest.a
to your system. Also see googletest primer in the googletest wiki of how to compile. Alternatively specify the library path for gcc-L<googleTestDir>/lib/.libs
and add-lgtest
to link with your test project executable. -
When using
ASSERT_DEATH
macro to check for asserts in your tested code (meaning asserts in your lib or application, not in googletest), callSetErrorMode
— example main:#include <windows.h> #include "gtest/gtest.h" int main (int argc, char** argv) { // this prevents annoying error message boxes popping up // when assert is called in your program code SetErrorMode(SEM_NOGPFAULTERRORBOX); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
answered Jun 17, 2014 at 8:53
michael_smichael_s
2,52518 silver badges24 bronze badges
You don’t need to copy the binaries as long as you have them in your path. Install python and CMake. Test them in your msys (MinGW console)
which cmake
which python
If you see the path, then you have the binaries. If not, add their path to your Environmental Variables>PATH or just update within msys (update installation paths if necessary)
export PATH=$PATH:/c/Program Files (x86)/CMake/bin/cmake.exe:/c/Python27/python.exe
Then you can build as suggested:
cd xxx/gtest-x.x.x
cmake -G "MSYS Makefiles"
make
Test if everything works:
cd make
make
./sample1_unittest.exe
answered Feb 27, 2015 at 13:50
HalilHalil
2,0861 gold badge22 silver badges30 bronze badges
With MSYS2, simply install the mingw-w64-x86_64-gtest package:
pacman -S mingw-w64-x86_64-gtest
Then compile tests with the flags -lgtest -lgtest_main
.
answered Jan 29 at 2:47
UnmitigatedUnmitigated
77.4k12 gold badges65 silver badges80 bronze badges
Before playing with the Google Test library, it’s necessary to install it.
This is what this tutorial is made of, a bunch of elements in order to set up it.
In our example, we are going to use Visual Studio 2017, so on Windows, without any Command-Line Interface (CLI) nor the RUN_ALL_TESTS() macro.
First of all
Two tools are necessary to realise this Google Test tutorial:
- Visual Studio
- Google Test
Visual Studio
We admit you have already downloaded Visual Studio 2017, but if not you can always do it.
In our case it’s the Community version:
- Visual Studio 2017 Community: https://www.visualstudio.com/downloads/
Google Test
Of course, we need the Google Test framework.
For our tutorial we are going to use the 1.8.0 version.
To know exactly which version you use, I recommend using the Google Test official web page from GitHub and pick the version you want (in our case the 1.8.0 release):
- Google Test 1.8.0: https://github.com/google/googletest/releases
For our tutorial I choose to install Google Test in the following directory:
- C:\dev\c++\mylib\googletest-release-1.8.0
Projects
From Visual Studio, we are going to create a solution with 3 different projects.
So from the New Project window, we’ll have for the first project:
- Name: BadprogProject
- Location: C:\dev\c++\vs\
- Solution name: Solution_1
For the second project:
- Name: BadprogProjectTests
- Location: C:\dev\c++\vs\Solution_1
For the third project:
- Name: GoogleTestFramework
- Location: C:\dev\c++\vs\Solution_1
Thus the solution is named Solution_1 and the 3 projects are:
- BadprogProject
- BadprogProjectTests
- GoogleTestFramework
As you can see, the first is the classic project, the second the testing project and the last the Google Test framework.
All projects will be without the Precompiled header option.
The reason here is that with this option the code won’t work properly, MSVC asking for some files such as stdafx.h even on extern libraries like Google Test.
And as we don’t want it, we unchecked the Precompiled header option on every project.
BadprogProject
This project is a Win32 Console Application with Additional options without Precompiled header (unchecked).
BadprogProjectTests
This project is a Win32 Console Application with Additional options wihtout Precompiled header (unchecked).
GoogleTestFramework
This project is a Win32 Console Application with Application type such as Static library and with Additional options without Precompiled header (unchecked).
Macros
Creating macros
As we have 3 projects using the same library (Google Test), we will create 2 macros: one for the Google Test home and the other for their includes.
From Visual Studio > View > Other Windows > Property Manager.
You should see now the 3 projects with 4 differents folders:
- Debug | Win32
- Debug | x64
- Release | Win32
- Release | x64
For this tutorial we will use only the Release | Win32 version, so free to you to use others if you want.
From the project of your choice (GoogleTestFramework for example).
Click the white triangle on the left side of Release | Win32 in order to display all parameters.
Inside you should see something like this:
- Microsoft.Cpp.Win32.user
- Whole Program Optimization
- Application
- Unicode Support
- Core Windows Libraries
So let’s take the first in the list (Microsoft.Cpp.Win32.user) and right click it > Properties.
The corresponding Property pages have appeared.
On the left, click Common Properties > User Macros.
Now on the right pane you click the Add Macro button.
The Add User Macro window has appeared.
Two text inputs must be filled:
- Name: GOOGLE_TEST_HOME
- Value: C:\dev\c++\mylib\googletest-release-1.8.0\googletest
Then check the option Set this macro as an environment variable in the build environment.
Click OK.
This macro is now added in the macro list.
Let’s add another one for the include folder:
- Name: GOOGLE_TEST_INCLUDE
- Value: C:\dev\c++\mylib\googletest-release-1.8.0\googletest\include
Once again check the option Set this macro as an environment variable in the build environment.
Now our 2 macros are ready, don’t forget to click Apply > OK.
Using macros
Let’s go back to our projects, from Visual Studio > View > Solution Explorer.
We are going to set each project with the new macros.
So right click the BadprogProject project then: Properties > Configuration Properties > C/C++ > General.
If you don’t see the C/C++ sub menu in the Configuration Properties, then you can instead use the VC++ Directories > Include Directories.
On the right side there is an Additional Include Directories parameter.
Click it and on the right you should see a drop down menu with an unique option: <Edit…>.
Click it.
The Include Directories have appeared.
On the bottom right, you have the Macros>> button, click it.
It should open a list of current macros used in your Visual Studion environment.
You can check that our new macros are present, search from the letter G to see them.
Unfortunately it’s impossible to directly copy them on the left.
So it was just to check that our macros are saved.
OK, on the left side, click the tiny folder icon to add a new include directory and type:
$(GOOGLE_TEST_HOME)
Then once again type:
$(GOOGLE_TEST_INCLUDE)
Don’t forget to add the parenthesis otherwise it won’t work.
On the Evaluated value pane (just under where you type the macros) you should see the full paths appear.
We have now our 2 include directories set.
Click OK to finish.
Then Apply > OK.
Do the same for the BadprogProjecTests.
And for the GoogleTestFramework, instead of using the C/C++ properties, use the following:
Right click GoogleTestFramework > Properties > VC++ Directories > On the right, select the Include Directories, and add the macros.
Adding some files
We have to add some files to the 3 projects.
BadprogProject
Right click > Add > New Item… > Header File (.h) > Calculation.h (as name) > Add.
Inside, type the following code:
// BadproG.com
#ifndef BADPROG_PROJECT_CALCULATION_H_
#define BADPROG_PROJECT_CALCULATION_H_
/**
* Adding the first parameter with the second.
*/
int add(const int first, const int second) {
return (first + second);
}
/**
* Substracting the first parameter with the second.
*/
int substract(const int first, const int second) {
return (first - second);
}
/**
* Multiplying the first parameter by the second.
*/
int multiply(const int first, const int second) {
return (first * second);
}
/**
* Dividing the first parameter by the second.
*/
int divide(const int first, const int second) {
return (first / second);
}
#endif
BadprogProjectTests
Delete everything and add the following code snippet to BadprogProjectTests.cpp:
// BadproG.com #include "gtest/gtest.h" #include "../BadprogProject/Calculation.h" // adding TEST(Test_Calculation, Adding) { EXPECT_EQ(5, add(2, 3)); EXPECT_EQ(-7, add(-2, -3)); } // substracting TEST(Test_Calculation, Substracting) { EXPECT_EQ(-1, substract(2, 3)); EXPECT_EQ(-7, substract(-2, -3)); } // multiplying TEST(Test_Calculation, Multiplying) { EXPECT_EQ(6, multiply(2, 3)); EXPECT_EQ(-7, multiply(-2, -3)); } // dividing TEST(Test_Calculation, Dividing) { EXPECT_EQ(2, divide(10, 5)); EXPECT_EQ(-7, divide(15, -3)); }
GoogleTestFramework
Right click GoogleTestFramework > Add > Existing Item… > then select the file:
- C:\dev\c++\mylib\googletest-release-1.8.0\googletest\include\gtest\gtest.h.
Do the same for the 2 following files:
- C:\dev\c++\mylib\googletest-release-1.8.0\googletest\src\gtest_main.cc
- C:\dev\c++\mylib\googletest-release-1.8.0\googletest\src\gtest-all.cc
By adding the gtest_main.cc in our project we skip the use of RUN_ALL_TESTS() macro and same for the ::testing::InitGoogleTest(&argc, argv) function.
Building the solution
Before building the solution we have to:
- Setting BadprogProjectTests as startup project.
- Adding GoogleTestFramework as reference.
1. Right click BadprogProjectTests > Set as StartUp Project.
2. From BadprogProjectTests, right click the References submenu > Add Reference… > Select GoogleTestFramework > OK.
Building the solution
It’s now time to rebuild the solution > Right click the Solution_1 > Rebuild Solution.
Everything should work and the following message appear in the Output:
1>------ Rebuild All started: Project: GoogleTestFramework, Configuration: Debug Win32 ------ 2>------ Rebuild All started: Project: BadprogProject, Configuration: Debug Win32 ------ 2>stdafx.cpp 1>gtest_main.cc 2>BadprogProject.cpp 2>Generating Code... 2>BadprogProject.vcxproj -> C:\dev\c++\vs\Solution_1\Debug\BadprogProject.exe 2>BadprogProject.vcxproj -> C:\dev\c++\vs\Solution_1\Debug\BadprogProject.pdb (Partial PDB) 1>gtest-all.cc 1>Generating Code... 1>GoogleTestFramework.vcxproj -> C:\dev\c++\vs\Solution_1\Debug\GoogleTestFramework.lib 3>------ Rebuild All started: Project: BadprogProjectTests, Configuration: Debug Win32 ------ 3>stdafx.cpp 3>BadprogProjectTests.cpp 3>Generating Code... 3>BadprogProjectTests.vcxproj -> C:\dev\c++\vs\Solution_1\Debug\BadprogProjectTests.exe 3>BadprogProjectTests.vcxproj -> C:\dev\c++\vs\Solution_1\Debug\BadprogProjectTests.pdb (Partial PDB) ========== Rebuild All: 3 succeeded, 0 failed, 0 skipped ==========
Testing our tests
Here we are, it’s time to see if all our work was useful.
From Visual Studio > Debug > Start Without Debugging.
The cmd.exe should appear with all RUN (in green) and FAILED (in red) tests.
And the following display:
Running main() from gtest_main.cc [==========] Running 4 tests from 1 test case. [----------] Global test environment set-up. [----------] 4 tests from Test_Calculation [ RUN ] Test_Calculation.Adding c:\dev\c++\vs\solution_1\badprogprojecttests\badprogprojecttests.cpp(10): error: Expected: -7 To be equal to: add(-2, -3) Which is: -5 [ FAILED ] Test_Calculation.Adding (1 ms) [ RUN ] Test_Calculation.Substracting c:\dev\c++\vs\solution_1\badprogprojecttests\badprogprojecttests.cpp(17): error: Expected: -7 To be equal to: multiply(-2, -3) Which is: 6 [ FAILED ] Test_Calculation.Substracting (1 ms) [ RUN ] Test_Calculation.Multiplying c:\dev\c++\vs\solution_1\badprogprojecttests\badprogprojecttests.cpp(24): error: Expected: -7 To be equal to: multiply(-2, -3) Which is: 6 [ FAILED ] Test_Calculation.Multiplying (1 ms) [ RUN ] Test_Calculation.Dividing c:\dev\c++\vs\solution_1\badprogprojecttests\badprogprojecttests.cpp(31): error: Expected: -7 To be equal to: add(15, -3) Which is: 12 [ FAILED ] Test_Calculation.Dividing (0 ms) [----------] 4 tests from Test_Calculation (4 ms total) [----------] Global test environment tear-down [==========] 4 tests from 1 test case ran. (5 ms total) [ PASSED ] 0 tests. [ FAILED ] 4 tests, listed below: [ FAILED ] Test_Calculation.Adding [ FAILED ] Test_Calculation.Substracting [ FAILED ] Test_Calculation.Multiplying [ FAILED ] Test_Calculation.Dividing 4 FAILED TESTS Press any key to continue . . .
Our those FAILED are normal.
Indeed, we passed wrong arguments in some our tests in order to test if the tests worked good.
Conclusion
An interesting way to learn a bit more how unit testing work with Google Test and Visual Studio.
Feel free now to change and adapt your tests on your needs.
Congratulations if you read until this point, you did it, good job!