#include "gtest/gtest.h"
TEST(BattleUnitTest, CountryReturnsProperName) {
EXPECT_EQ(1, 1);
}
int main(int argc, char* argv[]) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
我似乎无法让谷歌测试工作。我运行Nuget包管理器来获取gtest。它不断给我这些错误:不能让谷歌测试工作
Severity Code Description Project File Line
Error LNK2019 unresolved external symbol "bool __cdecl testing::internal::IsTrue(bool)" ([email protected]@[email protected]@[email protected]) referenced in function "public: void __thiscall testing::internal::scoped_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::reset(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" ([email protected][email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) Assignment1_Battle E:\C++\Projects\Assignment1_Battle\Assignment1_Battle\BattleUnitTest.obj 1
。
Severity Code Description Project File Line
Error LNK2019 unresolved external symbol "public: __thiscall testing::Message::Message(void)" ([email protected]@@[email protected]) referenced in function "private: virtual void __thiscall BattleUnitTest_CountryReturnsProperName_Test::TestBody(void)" ([email protected][email protected]@EAEXXZ) Assignment1_Battle E:\C++\Projects\Assignment1_Battle\Assignment1_Battle\BattleUnitTest.obj 1
。
Severity Code Description Project File Line
Error LNK2019 unresolved external symbol "class testing::AssertionResult __cdecl testing::internal::EqFailure(char const *,char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" ([email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "class testing::AssertionResult __cdecl testing::internal::CmpHelperEQ<int,int>(char const *,char const *,int const &,int const &)" ([email protected]@[email protected]@@[email protected]@[email protected]) Assignment1_Battle E:\C++\Projects\Assignment1_Battle\Assignment1_Battle\BattleUnitTest.obj 1
我可以发布所有的错误,但几乎所有的错误都与LNK2019有关。有谁知道如何解决这些错误?
正如我记得你必须在链接部分的输入字段中添加两个* .lib文件。 –
您正在收到链接器错误,因此您可能需要在项目中包含'gtest'库。看来你只包含了编译器查找头文件的路径。 –