|
Boost Users : |
Subject: Re: [Boost-users] Boost.Test BOOST_TEST/BOOST_REQUIRE_MESSAGE message arg problems
From: Olaf Peter (ope-devel_at_[hidden])
Date: 2018-07-23 17:28:09
>> How to get this?
>
> What about :
>
> 1- using test-case fixtures for writing things at the end of the test
> 2- registering an observer for getting the failure signal?
>
> The observer is (kind of) described here:
> https://www.boost.org/doc/libs/master/libs/test/doc/html/boost/unit_test/framework/register_observer.html
>
>
> You may install and remove it globally by using a global fixture:
>
> https://www.boost.org/doc/libs/master/libs/test/doc/html/boost_test/utf_reference/test_org_reference/test_org_boost_test_global_fixture.html
>
>
> Once registered, it will capture the events that you want, especially
> the failure cases.
>
> From the observer, you can get the current test cases with this
>
> https://www.boost.org/doc/libs/master/libs/test/doc/html/boost/unit_test/framework/current_test_case.html
>
OK, my test_observer_fixture with overloads is ready:
class test_observer_fixture
{
   struct test_observer : public utf::test_observer
   {
      virtual void test_unit_aborted(utf::test_unit const& tu) override;
      virtual void assertion_result(utf::assertion_result result)
override;
      // are the others required for my use case?
   };
   test_observer                           observer;
public:
   test_observer_fixture();
   ~test_observer_fixture();
public:
   void setup();
   void teardown();
};
and get called by my BOOST_DATA_TEST_CASE. What is the prefered way to
use this Fixture to save the test result in case of failure/abort?
BOOST_DATA_TEST_CASE( wave,
   utf_data::make_delayed<testsuite::dataset_loader>( "test_case/wave" ),
   input, expected, orig_file_name)
{
  ...
   auto [parse_ok, parse_result] = parse(input, parser, test_case_name);
   BOOST_REQUIRE(parse_ok);
   BOOST_TEST(parse_result == expected, btt::per_element());
      ??? my_diagnostic_saving .... (orig_file_name, input, parse_result);
   );
}
Thanks,
Olaf
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net