Boost logo

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:
> You may install and remove it globally by using a global fixture:
> 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

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)
 Â Â Â      // are the others required for my use case?
 Â Â Â  };

 Â Â Â  test_observer                                    observer;

 Â Â Â  test_observer_fixture();
 Â Â Â  ~test_observer_fixture();

 Â Â Â  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?

 Â Â Â  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);
 Â Â Â  );


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at