[Boost.Test] how to get current test outcome from within test case
This must be an FAQ but I haven't found the answer in the documentation. With Boost.Test, is there a way to know whether the current test case's success/failure status? Cheers pj
I am such an impatient lad, I answered my own question: #include <boost/test/results_collector.hpp> if ( boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).passed() ) { // do something useful. } Is there a better way? How about providing a tool wrapper for this feature? Cheers pj On 8/17/06, Pierre-Jules Tremblay <iamtrep@gmail.com> wrote:
This must be an FAQ but I haven't found the answer in the documentation. With Boost.Test, is there a way to know whether the current test case's success/failure status?
Cheers
pj
"Pierre-Jules Tremblay" <iamtrep@gmail.com> wrote in message news:4590bfef0608171408o5637d299s452bf55c19fbd6dd@mail.gmail.com...
I am such an impatient lad, I answered my own question:
#include <boost/test/results_collector.hpp>
if ( boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).passed() ) { // do something useful. }
Is there a better way?
Looks right. I would define a alias for boost::unit_test.
How about providing a tool wrapper for this feature?
Why do you need this? How frequent do you think this would be requested? Gennadiy
Well.. in general, not that often, I suppose. In our augmented version of your test framework, I've implemented fairly sophisticated logic to catch memory leaks on a per-test-case basis. In the results accounting, I need to know whether a test failed because of a memory leak or because it failed a predicate check. Come to think of it, perhaps this belongs more as an FAQ item for the documentation rather than a tool proper. pj On 8/17/06, Gennadiy Rozental <gennadiy.rozental@thomson.com> wrote:
"Pierre-Jules Tremblay" <iamtrep@gmail.com> wrote in message news:4590bfef0608171408o5637d299s452bf55c19fbd6dd@mail.gmail.com...
I am such an impatient lad, I answered my own question:
#include <boost/test/results_collector.hpp>
if ( boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).passed() ) { // do something useful. }
Is there a better way?
Looks right. I would define a alias for boost::unit_test.
How about providing a tool wrapper for this feature?
Why do you need this? How frequent do you think this would be requested?
Gennadiy
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
"Pierre-Jules Tremblay" <iamtrep@gmail.com> wrote in message news:4590bfef0608230550s5de6f427j45d531fbe6090cbd@mail.gmail.com...
Well.. in general, not that often, I suppose.
In our augmented version of your test framework, I've implemented fairly sophisticated logic to catch memory leaks on a per-test-case basis.
Would you be interrested t oshare it with us if it's generic enough?
In the results accounting, I need to know whether a test failed because of a memory leak or because it failed a predicate check.
Come to think of it, perhaps this belongs more as an FAQ item for the documentation rather than a tool proper.
Ok.
pj
On 8/17/06, Gennadiy Rozental <gennadiy.rozental@thomson.com> wrote:
"Pierre-Jules Tremblay" <iamtrep@gmail.com> wrote in message news:4590bfef0608171408o5637d299s452bf55c19fbd6dd@mail.gmail.com...
I am such an impatient lad, I answered my own question:
#include <boost/test/results_collector.hpp>
if ( boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).passed() ) { // do something useful. }
Is there a better way?
Looks right. I would define a alias for boost::unit_test.
How about providing a tool wrapper for this feature?
Why do you need this? How frequent do you think this would be requested?
Gennadiy
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 8/23/06, Gennadiy Rozental <gennadiy.rozental@thomson.com> wrote:
"Pierre-Jules Tremblay" <iamtrep@gmail.com> wrote in message news:4590bfef0608230550s5de6f427j45d531fbe6090cbd@mail.gmail.com...
Well.. in general, not that often, I suppose.
In our augmented version of your test framework, I've implemented fairly sophisticated logic to catch memory leaks on a per-test-case basis.
Would you be interrested t oshare it with us if it's generic enough?
I've been thinking about that. At the moment, it's not possible because much of the code depends on a proprietary heap management library. However I think it should be possible to abstract that out. Perhaps it would be useful if it could at least make use of Microsoft's debug CRT functions? I'll let you know if I get anywhere with generalizing the memory-leak finding code.
In the results accounting, I need to know whether a test failed because of a memory leak or because it failed a predicate check.
Come to think of it, perhaps this belongs more as an FAQ item for the documentation rather than a tool proper.
Ok.
pj
On 8/17/06, Gennadiy Rozental <gennadiy.rozental@thomson.com> wrote:
"Pierre-Jules Tremblay" <iamtrep@gmail.com> wrote in message news:4590bfef0608171408o5637d299s452bf55c19fbd6dd@mail.gmail.com...
I am such an impatient lad, I answered my own question:
#include <boost/test/results_collector.hpp>
if ( boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).passed() ) { // do something useful. }
Is there a better way?
Looks right. I would define a alias for boost::unit_test.
How about providing a tool wrapper for this feature?
Why do you need this? How frequent do you think this would be requested?
Gennadiy
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Gennadiy Rozental
-
Pierre-Jules Tremblay