如何使用Catch2测试Visual Studio中的大型项目
我在2019年的Visual Studio中有一个大项目。
我想通过catch2库对其进行测试。
我想知道如何正确包含我的项目吗?
,在main.cpp中。
#include <header1>
#include <header2>
#define CATCH_CONFIG_MAIN
#include <catch/catch.hpp> // header only library
void function_1()
{
// do something
}
void function_2()
{
// do something
}
// int main()
// {
TEST_CASE("My test number 1", "[Test1]")
{
function_1();
function_2();
}
// return 0;
// }
例如 喜欢
main.obj : error LNK2001: unresolved external symbol "public: __cdecl Catch::AutoReg::AutoReg(struct Catch::ITestInvoker *,struct Catch::SourceLineInfo const &,class Catch::StringRef const &,struct Catch::NameAndTags const &)" (??0AutoReg@Catch@@QEAA@PEAUITestInvoker@1@AEBUSourceLineInfo@1@AEBVStringRef@1@AEBUNameAndTags@1@@Z).
这样,我应该如何正确编写代码以使用catch2库?
I have a big project in Visual Studio 2019.
And I want to test it by Catch2 library.
I'd like to know how to include this library correctly in my project?
For example, in main.cpp I do:
#include <header1>
#include <header2>
#define CATCH_CONFIG_MAIN
#include <catch/catch.hpp> // header only library
void function_1()
{
// do something
}
void function_2()
{
// do something
}
// int main()
// {
TEST_CASE("My test number 1", "[Test1]")
{
function_1();
function_2();
}
// return 0;
// }
After that I get a lot of errors like
main.obj : error LNK2001: unresolved external symbol "public: __cdecl Catch::AutoReg::AutoReg(struct Catch::ITestInvoker *,struct Catch::SourceLineInfo const &,class Catch::StringRef const &,struct Catch::NameAndTags const &)" (??0AutoReg@Catch@@QEAA@PEAUITestInvoker@1@AEBUSourceLineInfo@1@AEBVStringRef@1@AEBUNameAndTags@1@@Z).
So, how should I write my code correctly to use Catch2 library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论