googletest

MFC gui testable with google test?

◇◆丶佛笑我妖孽 提交于 2020-01-06 06:58:31
问题 I have been using gtest as my C++ unit-test framework, and it works great for console applications. Does anybody know if it is possible to use this (or which would be a good alternative) for testing an MFC application? I mean, make an automatic test depending on the events of the GUI (text inside text-boxes, buttons clicks and so). I have seen applications like TestComplete, but I would like to know if gtest offers something similar or if there is a free/opensource alternative to start with.

Is it possible to ASSERT_DOES_NOT_COMPILE with GTest?

孤街浪徒 提交于 2020-01-05 17:37:47
问题 Assume a template class where we assert at compile time that the integer template argument must be greater zero: template<int N> class A { public: A() { static_assert(N > 0, "N needs to be greater 0."); } }; Is it possible to create a googletest unit test that compiles , but reports the error at runtime ? For example: TEST(TestA, ConstructionNotAllowedWithZero) { ASSERT_DOES_NOT_COMPILE( { A< 0 > a; } ); } 回答1: There is a way, but sadly it's probably not the way you want. My first thought was

using gtest with xcode

人盡茶涼 提交于 2020-01-05 10:12:46
问题 I'm trying to set up a c++ unit testing library on my computer and figured that google's gtest would be a good fit. I am currently running mountain lion with the most recent release of xcode. I have been attempting to follow the instructions found here but am running into an intresting problem. I am opening the gtest project, building it, and even though xcode tells me that the build was successful, I cant seem to find the framework anywhere. any help on this subject would be highly

How to suppress termination in Google test when assert() unexpectedly triggers?

ぃ、小莉子 提交于 2020-01-05 06:42:14
问题 Here it's discussed how to catch failing assert, e.g. you setup your fixture so that assert() fails and you see nice output. But what I need is the opposite. I want to test that assert() succeeds. But in case it fails I want to have nice output. At that point it just terminates when it snags on assert(). #define LIMIT 5 struct Obj { int getIndex(int index) { assert(index < LIMIT); // do stuff; } } Obj obj; TEST(Fails_whenOutOfRange) { ASSERT_DEATH(obj->getIndex(6), ""); } TEST(Succeeds

Linking google test to your main project

霸气de小男生 提交于 2020-01-04 05:47:11
问题 I am new to the gtest. I have followed a tutorial how to set it up in the VS 2105. But all that I could find talked about how to build and link gtest. I am passed that level. The code below runs and passes the first dummy test. #include "gtest/gtest.h" TEST(VI, simple) { EXPECT_EQ(false, false); } int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); RUN_ALL_TESTS(); std::cin.get(); return 0; } My question: How do I exactly hook it up to my project that I want to test? Both

C++ Multiple parameters with GTest TYPED_TEST

主宰稳场 提交于 2020-01-04 03:18:29
问题 I have fallowing sets of tests: TEST_F(FactoryShould, createAFromAModule) { const auto stateMachine = createStateMachine(EModule_A); const auto* typedStateMachine = dynamic_cast<const BackEnd<transitiontable::A, Guard>*>(stateMachine.get()); ASSERT_TRUE(typedStateMachine); } TEST_F(FactoryShould, createBFromBModule) { const auto stateMachine = createStateMachine(EModule_B); const auto* typedStateMachine = dynamic_cast<const BackEnd<transitiontable::B, Guard>*>(stateMachine.get()); ASSERT_TRUE

Viewing Google Test results within Visual Studio

折月煮酒 提交于 2020-01-03 07:07:18
问题 Is there a way to view Google Test results within Visual Studio? If yes, how? I'm using Google Test 1.5.0 and Visual Studio 2010 Until now I've been using Google Test from the command line. I've seen such integrations on other IDEs (eclipse...) but not yet in VS 回答1: Look at GoogleTestAddin - I think it's what you want. Quoting from the CodePlex description: GoogleTestAddin is an Add-In for Visual Studio 2008 and 2010. It makes it easier to execute/debug googletest functions by selecting them

Free automated Testing tools for MFC based GUI App

两盒软妹~` 提交于 2020-01-02 09:57:19
问题 I am a complete newbie to Windows development and test platforms. I am working on a legacy MFC based GUI application and looking for tools that would help with automated testing of the UI. A whole bunch of tools came up when I searched but most of them don't seem to support MFC. The options I considered were: a. Coded UI/ UI Automation - Seems like a good fit but not supported in Visual Studio Professional 2012 (which is my dev env). b. Google test - no MFC support ? (Pls share any pointers

How to unit test BSD sockets [closed]

空扰寡人 提交于 2020-01-01 11:53:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I am writing a server/client based C++ application in Ubuntu with BSD socket. I am using Google C++ Test Framework as my unit test framework. I wonder is there a way that I can create a server and client in my unit test, so I can test listen/accept for the server, and send/receive

CMake conflict with multiple gtest

雨燕双飞 提交于 2020-01-01 09:18:13
问题 This is my first post on StackOverflow, so apologies if there's something wrong with my question. I'm new at CMake, and I'm running into a problem trying to import gtest (Google Test) in a C++ project with an existing gtest directory used within a library. My root CMakeLists.txt file is this (My changes are made between "Begin changes" and "End changes") : cmake_minimum_required(VERSION 2.6) project(nifi-minifi-cpp) set(PROJECT_NAME "nifi-minifi-cpp") set(PROJECT_VERSION_MAJOR 0) set(PROJECT