googletest

Why does Google Test not print a stack trace or file name?

拥有回忆 提交于 2019-12-10 20:59:25
问题 When I use Google Test and Google Mock, with diagnostic level set to "info", I get messages like this: Uninteresting mock function call - taking default action specified at: src/pkgtest/test_Foo.cpp:216: Function call: GetBar() Returns: 4-byte object <00-00 00-00> Stack trace: Uninteresting mock function call - taking default action specified at: src/pkgtest/test_Foo.cpp:126: Function call: GetBaz() Returns: {} Stack trace: unknown file: Failure C++ exception with description "Uninteresting

How can I tell Cppcheck to skip a header file

隐身守侯 提交于 2019-12-10 16:52:56
问题 Cppcheck scans all files in a project folder: c:\projectfolder\main.c c:\projectfolder\file.c c:\projectfolder\file.h c:\projectfolder\file_test.cc c:\projectfolder\file_test.cc contains the following code #include "c:/gtest/gtest.h" extern "C" { #include "TMyStruct.h" } TEST(Stack, Overflow) { TMyStruct unterTest; EXPECT_EQ(1, TMyStruct_Init(&unterTest)); EXPECT_GE(unterTest.variable, 9000); } File file_test.cc includes the gtest.h file C:\gtest\gtest.h All files in C:\gtest\ should not be

How to Configure GoogleMock in Visual Studio 2017 After Already Installing GoogleTest?

笑着哭i 提交于 2019-12-10 14:49:59
问题 I installed the Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn package into my VS 2017 application solution. This was accomplished by adding a new GoogleTest project to my solution via "Add New Project/Other Languages/C++/Test/Google Test". The testing works well, but now I am ready to try some mocking with gmock. So, I installed googlemock.v140.windesktop.static.rt-dyn via NuGet, but I have no idea of how to get it integrated into my test project. My packages.config looks like

mock method with 11 parameters with gmock

邮差的信 提交于 2019-12-10 13:36:37
问题 I'm using gmock to mock my dependencies in legacy code. One of the class have a method with 11 parameters. When I tried to use MOCK_METHOD11_WITH_CALLTYPE to mock it, I found this macro doesn't exist. gmock only supoort up to 10 parameters. What do you suggest for this? Do I implement this method with dummy body? Or copy & extend the macro? Thanks! PS, I don't need to mock this method in my tests right now, but probably need to do so in the future. Best regards, 回答1: Methods with more than 10

CMake Error: “add_subdirectory not given a binary directory”

限于喜欢 提交于 2019-12-10 13:24:26
问题 I am trying to integrate Google Test into the subproject of bigger project and I cannot find the solution that would be satisfying for me. I have two constraints: - the source code of Google Test is already somewhere in the project structure (thus using URL to download it from git repository is not an option) - the source code of Google Test is not a subdirectory of my subproject (and never will) So when I tried to do something like this: add_subdirectory( ${GOOGLETEST_PROJECT_LOCATION}) I

What libraries do I need to link to build a googlemock example?

冷暖自知 提交于 2019-12-10 13:21:15
问题 I'm able to compile googlemock v1.6.x in VS2010 and produce both release and debug libraries. In other words, the issue I have is NOT this GoogleMock and GoogleTest in Visual Studio 2010 Now I'm following the example here http://code.google.com/p/googlemock/wiki/ForDummies, and I'm having these errors. I did link the generated *.lib files and added the correct library directory in VS2010. So what else do I need to link? 1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::

GoogleTest: Accessing the Environment from a Test

我的梦境 提交于 2019-12-10 12:53:25
问题 I'm trying out gtest for C++ (Google's unit testing framework), and I've created a ::testing::Environment subclass to initialize and keep track of some things that I need for most of my tests (and don't want to setup more than once). My question is: How do I actually access the contents of the Environment object? I guess I could theoretically save the Environment in a global variable in my test project, but is there a better way? I'm trying to make tests for some already existing (very

How to mark a Google Test test-case as “expected to fail”?

半腔热情 提交于 2019-12-10 12:43:15
问题 I want to add a testcase for functionality not yet implemented and mark this test case as " it's ok that I fail ". Is there a way to do this? EDIT: I want the test to be executed and the framework should verify it is failing as long as the testcase is in the "expected fail" state. EDIT2: It seems that the feature I am interested in does not exist in google-test, but it does exist in the Boost Unit Test Framework, and in LIT. 回答1: You can prefix the test name with DISABLED_. 回答2: I'm not aware

GoogleTest C++ - Test Fixture

大兔子大兔子 提交于 2019-12-10 11:25:03
问题 I'm a beginner in C++ and am coding a Snake for uni, and have to run unit tests. FYI, I code on Xcode 7.1.1. I manage to make sample tests run on my machine, but have a problem when it comes to creating a fixture for my snake. Here is the code I have : #include "gtest/gtest.h" #include "calc.h" #include "Serpent.h" #include "Map.h" #include "Main.h" using namespace std; using namespace sf; class Serpent_test_fixture: public ::testing::Test {public: Serpent* serpent_test; Map* map_test;

Google Mock: Is it ok to use global mock objects?

本秂侑毒 提交于 2019-12-10 09:44:16
问题 In all the documentation about gmock I always find the mock object to be instantiated inside a test, like that: TEST(Bim, Bam) { MyMockClass myMockObj; EXPECT_CALL(MyMockObj, foo(_)); ... } So, the object is created and destroyed per test. I believe it's also perfectly fine to create and destroy the object per test fixture . But I'm wondering if it's also ok to have a file-global instance of the mock object, like that: MyMockClass myMockObj; TEST(Bim, Bam) { EXPECT_CALL(MyMockObj, foo(_)) ...