2

谁能告诉我如何以及何时在 cppunit 中调用 setup 和 teardown 函数。谢谢

4

2 回答 2

6

在每个测试函数运行之前调用 setup,在每个测试函数运行之后,调用 teardown

于 2010-11-15T14:25:47.173 回答
1

You use a TestFixture to isolate each test - setUp and tearDown can be overridden to perform test-specific initialization and termination logic.

Detailed Description

Wraps a test case with setUp and tearDown methods. A TestFixture is used to provide a common environment for a set of test cases.

To define a test fixture, do the following:

  • implement a subclass of TestCase
  • the fixture is defined by instance variables
  • initialize the fixture state by overriding setUp (i.e. construct the instance variables of the fixture)
  • clean-up after a test by overriding tearDown.
于 2010-11-15T14:27:30.100 回答