#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'庫。看來你只包含了編譯器查找頭文件的路徑。 –