草庐IT

c++ - 测试夹具中的设置与构造函数

为什么测试夹具在GoogleTest中有一个SetUp方法?构造函数实际上不是同一件事吗?对于TearDown方法也是如此。对SetUp和Constructor以及TearDown和Destructor的调用与TestEventListener一致:OnTestStart和OnTestEnd。 最佳答案 有ananswertothatintheFAQ:ShouldIusetheconstructor/destructorofthetestfixtureortheset-up/tear-downfunction?Thefirstthi