I tried to introduce Google Test to unit test the library I made in C language. Google Test is a C / C ++ testing framework.
Google Test already exists as a project template for Visual Studio 2019 It's easy to use Google Test header files (gtest.h, etc.), I had a hard time with the introduction of Google Mock, so I will introduce the solution.
How to install Google Test / Google Mock You can also download the source code from GitHub, build it, etc. This introduction method is to install Google Mock using NuGet of __Visual Studio __. Complete only on Visual Studio.
Google Test As mentioned earlier, Google Test already exists as a project template for Visual Studio 2019. It's easy to deploy. Select Google Test from Create Project. Detailed settings will be omitted this time.
Google Mock
I installed the Google Mock package from NuGet.
If you search on Google Mock, you will find some hits.
This time, I installed 1.7.0.1
of googlemock.v140.windesktop.static.rt-dyn
.
After installation, the project config file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="googlemock" version="1.10.0" targetFramework="native" />
<package id="Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn" version="1.8.1.3" targetFramework="native" />
</packages>
I think it will be like this.
You can see that googlemock
has been added.
Now that the installation is complete, I get an error that the location cannot be found when I include gmock / gmock.h
to use Google Mock.
If you look at the location of the Google Mock package you installed for trial (project location \ packages \ googlemock.v140.windesktop.static.rt-dyn.1.7.0.1
)
The directory name under ʻinclude was
gtest`.
Isn't it __gmock
? ?? ?? ?? __
So by changing the directory name from gtest
to gmock
You can now include it safely (^ ω ^)
Recommended Posts