pauloalves1986

Boost.Test and Google Mock

Feb 24th, 2012
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. class BoostTestAdapter
  2.     : public ::testing::EmptyTestEventListener {
  3.   void OnTestPartResult(const ::testing::TestPartResult& testPartResult) {
  4.     if (!testPartResult.failed()) return;
  5.     ::boost::test_tools::tt_detail::check_impl(
  6.         false,
  7.         ::boost::unit_test::lazy_ostream::instance() << testPartResult.summary(),
  8.         testPartResult.file_name(),
  9.         testPartResult.line_number(),
  10.         ::boost::test_tools::tt_detail::CHECK,
  11.         ::boost::test_tools::tt_detail::CHECK_MSG,
  12.         0);
  13.   }
  14. };
  15.  
  16. struct GoogleMockFixture {
  17.   GoogleMockFixture() {
  18.     ::testing::InitGoogleMock(
  19.         &boost::unit_test::framework::master_test_suite().argc,
  20.         boost::unit_test::framework::master_test_suite().argv);
  21.     ::testing::TestEventListeners &listeners = ::testing::UnitTest::GetInstance()->listeners();
  22.     delete listeners.Release(listeners.default_result_printer());
  23.     listeners.Append(new BoostTestAdapter);
  24.   }
  25.   ~GoogleMockFixture() {}
  26. };
  27.  
  28. BOOST_GLOBAL_FIXTURE(GoogleMockFixture)
Add Comment
Please, Sign In to add comment