Skip to content

Instantly share code, notes, and snippets.

@ashe23
Last active December 23, 2016 17:40
Show Gist options
  • Select an option

  • Save ashe23/8b37db05adedecf2366d24e7ebd95416 to your computer and use it in GitHub Desktop.

Select an option

Save ashe23/8b37db05adedecf2366d24e7ebd95416 to your computer and use it in GitHub Desktop.
Google Test with cmake
GoogleTest link - https://github.com/google/googletest
cmake_minimum_required(VERSION 3.6)
project(sandbox)
add_subdirectory(googletest-master)
include_directories(googletest-master/googletest/include)
include_directories(googletest-master/googlemock/include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp SimpleTest.cpp)
add_executable(sandbox ${SOURCE_FILES})
target_link_libraries(sandbox gtest gtest_main)
#include <gtest/gtest.h>
#include <gmock/gmock.h>
using namespace std;
int main(int argc, char *argv[]) {
//Initializing GoogleTest
testing::InitGoogleTest(&argc, argv);
RUN_ALL_TESTS();
return 0;
}
#include <gtest/gtest.h>
#include <gmock/gmock.h>
using testing::Eq;
TEST(ShouldReturn2, toBe2) {
EXPECT_EQ(2, 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment