当我运行一个GoogleTest可执行文件时,我创建了两个测试,无论每个测试的通过或失败结果是什么,我得到以下输出:
[==========] Running 0 tests from 0 test cases.
[==========] 0 tests from 0 test cases ran. (0 ms total)
[ PASSED ] 0 tests.
Main_TestAll.C:
#include "gtest/gtest.h"
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Env_Test.C:
#include "gtest/gtest.h"
#include <Environment.h>
class EnvTest : public ::testing::Test
{
protected:
virtual void SetUp()
{
}
virtual void TearDown()
{
}
}
TEST_F(EnvTest, getValue1)
{
const char *one = "1";
Environment *myEnv = new Environment("./default.cfg");
myEnv->setValue("general", "foo", one);
EXPECT_STREQ(one, myEnv->getValue("foo"));
}
TEST_F(EnvTest, getValue2)
{
const char *two = "2";
Environment *myEnv = new Environment("./default.cfg");
myEnv->setValue("general", "foo", two);
EXPECT_STREQ(two, myEnv->getValue("foo"));
}
的CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(tools_environment_test)
include_directories(
${Environment_SOURCE_DIR}
)
set(GTESTSRCS
Main_TestAll.C
Env_Test.C
)
add_getest_test(Env
${GTESTSRCS}
)
add_library(Env
${GTESTSRCS}
)
add_getest_test是我们用于编译和链接gtests的宏。
有什么想法吗?