trompeloeil
trompeloeil copied to clipboard
doctest: Trompeloeil error reporting via doctest/trompeloeil.hpp gives unhelpful output
Environment: Trompeloeil v42, doctest v2.4.9 from conan packages. G++-11
When a trompeloeil expectation fails, doctest only reports an address, which makes it harder to understand what the actual error was:
[doctest] run with "--help" for options
===============================================================================
/tmp/trompeloeil_test.cpp:46:
Scenario: trompeloeil + doctest error reporting works
/tmp/trompeloeil_test.cpp:50: ERROR: 0x55af94acfb20
===============================================================================
[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped
[doctest] assertions: 1 | 0 passed | 1 failed |
[doctest] Status: FAILURE!
A test program to reproduce this is:
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest/doctest.h"
#include "doctest/trompeloeil.hpp"
class Test
{
public:
MAKE_MOCK0(x, void());
};
SCENARIO("trompeloeil + doctest error reporting works")
{
Test t;
REQUIRE_CALL(t, x());
}
And the problem can be fixed by passing a std::string to DOCTEST_ADD_FAIL_MESSAGE from reporter<specialized>::send():
DOCTEST_ADD_FAIL_CHECK_AT(f, line, std::string(msg));
Interesting. This seems to be caused by a change in doctest. The same in 2.3.8 works.
https://godbolt.org/z/31czP6hTo
I'll look into it. Thanks.
Can you try with the branch fix_doctest_adapter, which I think should solve your problem?
Works fine!
[doctest] doctest version is "2.4.9"
[doctest] run with "--help" for options
===============================================================================
/tmp/trompeloeil_test.cpp:12:
Scenario: trompeloeil + doctest error reporting works
/tmp/trompeloeil_test.cpp:16: ERROR: Unfulfilled expectation:
Expected t.x() to be called once, actually never called
===============================================================================
[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped
[doctest] assertions: 1 | 0 passed | 1 failed |
[doctest] Status: FAILURE!
the only comment I have on the commit is that my name is misspelled in the ChangeLog :-)
Ops. Fixed.
Leaving this open until a release has been tagged.
Just released v43 which includes this fix. Closing now.