From UnitTest++ to GoogleTest

2009/06/25
By

We’ve decided to replace UnitTest++ with googletest

The first thing to notice:

Remember, when they fail, ASSERT_* yields a fatal failure and returns from the current function, while EXPECT_* yields a nonfatal failure, allowing the function to continue running. In either case, an assertion failure means its containing test fails.

Remarkable modification:

  • CHECK => (ASSERT|EXPECT)_TRUE
  • CHECK_EQUAL => (ASSERT|EXPECT)_EQ
  • CHECK_EQUAL => (ASSERT|EXPECT)_STREQ (if you’re comparing strings, such as (char *result)
  • For Test Fixture, UnitTest++ only provides constructor/destructor for SetUp()/TearDown(), where Google Test provides SetUp()/TearDown().
  • Note that different tests in the same test case have different test fixture objects, and Google Test always deletes a test fixture before it creates the next one. Google Test does not reuse the same test fixture for multiple tests. Any changes one test makes to the fixture do not affect other tests.

The best thing what unittest++ doesn’t have, but gtest has:

  • Getting the Current Test’s Name
  • Sometimes a function may need to know the name of the currently running test. For example, you may be using the SetUp() method of your test fixture to set the golden file name based on which test is running.

Reference:

Tags: , ,

2 Responses to From UnitTest++ to GoogleTest

  1. jeffhung on 2009/06/30 at 2:10 下午

    What makes you decide to switch test framework?

  2. clsung on 2009/07/01 at 9:17 上午

    According to the dev team’s commits, reponses to comment, and activities :p

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*


*