Thread: [Cppunit-devel] Exception handler
Brought to you by:
blep
|
From: Noel Y. <Noe...@mo...> - 2003-02-25 18:00:56
|
In our project, we typically inherit from one of our base exception types. It would be nice to be able to register with CppUnit an exception handler that would call a method on our exception. I've looked through the source and it doesn't look like this is possible currently. Can this be put on the TODO list, please? (I'll see if I can work on it if I get some free time). Thanks, Noel -- NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited. |
|
From: Baptiste L. <gai...@fr...> - 2003-02-26 07:39:57
|
Give a look to class Protector (available since 1.9.10). It allow interception of non STL exception. Check the implementation of the DefaultProtector for an example of usage. Baptiste. ----- Original Message ----- From: "Noel Yap" <Noe...@mo...> To: <cpp...@li...> Sent: Tuesday, February 25, 2003 7:00 PM Subject: [Cppunit-devel] Exception handler > In our project, we typically inherit from one of our base exception > types. It would be nice to be able to register with CppUnit an > exception handler that would call a method on our exception. > > I've looked through the source and it doesn't look like this is possible > currently. Can this be put on the TODO list, please? (I'll see if I > can work on it if I get some free time). > > Thanks, > Noel > -- > NOTICE: If received in error, please destroy and notify sender. Sender > does not waive confidentiality or privilege, and use is prohibited. > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Cppunit-devel mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppunit-devel > |
|
From: Noel Y. <Noe...@mo...> - 2003-02-26 21:36:54
|
Baptiste Lepilleur wrote: > > Give a look to class Protector (available since 1.9.10). It allow > interception of non STL exception. Check the implementation of the > DefaultProtector for an example of usage. This looks good except that I'm using a TextTestRunner and it hides TestRunner::run( Protector* ). Would it hurt anything if a using declaration were used? Thanks, Noel -- NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited. |
|
From: Noel Y. <Noe...@mo...> - 2003-02-26 21:52:11
|
Noel Yap wrote: > > Baptiste Lepilleur wrote: > > > > Give a look to class Protector (available since 1.9.10). It allow > > interception of non STL exception. Check the implementation of the > > DefaultProtector for an example of usage. > > This looks good except that I'm using a TextTestRunner and it hides > TestRunner::run( Protector* ). > > Would it hurt anything if a using declaration were used? I just found out that, since TextTestRunner::run() returns bool and TestRunner::run() returns void, this is not the right thing to do. Can you help me out, please? How can I use a TextTestRunner with a custom Protector? Thanks, Noel |
|
From: Baptiste L. <gai...@fr...> - 2003-02-27 07:12:55
|
You need to get the TestResult and use the following methods: /// Adds the specified protector to the protector chain. virtual void pushProtector( Protector *protector ); /// Removes the last protector from the protector chain. virtual void popProtector(); Baptiste. ----- Original Message ----- From: "Noel Yap" <Noe...@mo...> To: "Baptiste Lepilleur" <gai...@fr...> Cc: <cpp...@li...> Sent: Wednesday, February 26, 2003 10:36 PM Subject: Re: [Cppunit-devel] Exception handler > Baptiste Lepilleur wrote: > > > > Give a look to class Protector (available since 1.9.10). It allow > > interception of non STL exception. Check the implementation of the > > DefaultProtector for an example of usage. > > This looks good except that I'm using a TextTestRunner and it hides > TestRunner::run( Protector* ). > > Would it hurt anything if a using declaration were used? > > Thanks, > Noel > -- > NOTICE: If received in error, please destroy and notify sender. Sender > does not waive confidentiality or privilege, and use is prohibited. > |
|
From: Noel Y. <Noe...@mo...> - 2003-02-27 13:28:44
|
I'm using TestResult::pushProtector(), but how can I use the testResult
object with CppUnit::TextUi::TestRunner?
Here's a snippet of my code:
CppUnit::TextUi::TestRunner testRunner;
.
.
.
testResult.pushProtector( &messageExceptionProtector );
testRunner.addTest( testSuite.release() );
if( testRunner.run( testResult ) ) // can't do this, no such method
{
result = EXIT_SUCCESS;
}
Thanks,
Noel
Baptiste Lepilleur wrote:
>
> You need to get the TestResult and use the following methods:
>
> /// Adds the specified protector to the protector chain.
> virtual void pushProtector( Protector *protector );
>
> /// Removes the last protector from the protector chain.
> virtual void popProtector();
>
> Baptiste.
>
> ----- Original Message -----
> From: "Noel Yap" <Noe...@mo...>
> To: "Baptiste Lepilleur" <gai...@fr...>
> Cc: <cpp...@li...>
> Sent: Wednesday, February 26, 2003 10:36 PM
> Subject: Re: [Cppunit-devel] Exception handler
>
> > Baptiste Lepilleur wrote:
> > >
> > > Give a look to class Protector (available since 1.9.10). It allow
> > > interception of non STL exception. Check the implementation of the
> > > DefaultProtector for an example of usage.
> >
> > This looks good except that I'm using a TextTestRunner and it hides
> > TestRunner::run( Protector* ).
> >
> > Would it hurt anything if a using declaration were used?
> >
> > Thanks,
> > Noel
> > --
> > NOTICE: If received in error, please destroy and notify sender. Sender
> > does not waive confidentiality or privilege, and use is prohibited.
> >
--
NOTICE: If received in error, please destroy and notify sender. Sender
does not waive confidentiality or privilege, and use is prohibited.
|
|
From: Baptiste L. <gai...@fr...> - 2003-02-27 18:25:23
|
You can get the TestResult by the TestRunner using the method
eventManager(). See the doxygen documentation for that class.
Baptiste.
----- Original Message -----
From: "Noel Yap" <Noe...@mo...>
To: "Baptiste Lepilleur" <gai...@fr...>
Cc: <cpp...@li...>
Sent: Thursday, February 27, 2003 2:28 PM
Subject: Re: [Cppunit-devel] Exception handler
> I'm using TestResult::pushProtector(), but how can I use the testResult
> object with CppUnit::TextUi::TestRunner?
>
> Here's a snippet of my code:
> CppUnit::TextUi::TestRunner testRunner;
>
> .
> .
> .
>
> testResult.pushProtector( &messageExceptionProtector );
>
> testRunner.addTest( testSuite.release() );
> if( testRunner.run( testResult ) ) // can't do this, no such method
> {
> result = EXIT_SUCCESS;
> }
>
> Thanks,
> Noel
>
> Baptiste Lepilleur wrote:
> >
> > You need to get the TestResult and use the following methods:
> >
> > /// Adds the specified protector to the protector chain.
> > virtual void pushProtector( Protector *protector );
> >
> > /// Removes the last protector from the protector chain.
> > virtual void popProtector();
> >
> > Baptiste.
> >
> > ----- Original Message -----
> > From: "Noel Yap" <Noe...@mo...>
> > To: "Baptiste Lepilleur" <gai...@fr...>
> > Cc: <cpp...@li...>
> > Sent: Wednesday, February 26, 2003 10:36 PM
> > Subject: Re: [Cppunit-devel] Exception handler
> >
> > > Baptiste Lepilleur wrote:
> > > >
> > > > Give a look to class Protector (available since 1.9.10). It allow
> > > > interception of non STL exception. Check the implementation of the
> > > > DefaultProtector for an example of usage.
> > >
> > > This looks good except that I'm using a TextTestRunner and it hides
> > > TestRunner::run( Protector* ).
> > >
> > > Would it hurt anything if a using declaration were used?
> > >
> > > Thanks,
> > > Noel
> > > --
> > > NOTICE: If received in error, please destroy and notify sender.
Sender
> > > does not waive confidentiality or privilege, and use is prohibited.
> > >
>
> --
> NOTICE: If received in error, please destroy and notify sender. Sender
> does not waive confidentiality or privilege, and use is prohibited.
>
|
|
From: Noel Y. <Noe...@mo...> - 2003-02-27 18:48:16
|
I see. I had to turn my thinking inside-out.
This works great.
Thanks a bunch,
Noel
Baptiste Lepilleur wrote:
>
> You can get the TestResult by the TestRunner using the method
> eventManager(). See the doxygen documentation for that class.
>
> Baptiste.
>
> ----- Original Message -----
> From: "Noel Yap" <Noe...@mo...>
> To: "Baptiste Lepilleur" <gai...@fr...>
> Cc: <cpp...@li...>
> Sent: Thursday, February 27, 2003 2:28 PM
> Subject: Re: [Cppunit-devel] Exception handler
>
> > I'm using TestResult::pushProtector(), but how can I use the testResult
> > object with CppUnit::TextUi::TestRunner?
> >
> > Here's a snippet of my code:
> > CppUnit::TextUi::TestRunner testRunner;
> >
> > .
> > .
> > .
> >
> > testResult.pushProtector( &messageExceptionProtector );
> >
> > testRunner.addTest( testSuite.release() );
> > if( testRunner.run( testResult ) ) // can't do this, no such method
> > {
> > result = EXIT_SUCCESS;
> > }
> >
> > Thanks,
> > Noel
> >
> > Baptiste Lepilleur wrote:
> > >
> > > You need to get the TestResult and use the following methods:
> > >
> > > /// Adds the specified protector to the protector chain.
> > > virtual void pushProtector( Protector *protector );
> > >
> > > /// Removes the last protector from the protector chain.
> > > virtual void popProtector();
> > >
> > > Baptiste.
> > >
> > > ----- Original Message -----
> > > From: "Noel Yap" <Noe...@mo...>
> > > To: "Baptiste Lepilleur" <gai...@fr...>
> > > Cc: <cpp...@li...>
> > > Sent: Wednesday, February 26, 2003 10:36 PM
> > > Subject: Re: [Cppunit-devel] Exception handler
> > >
> > > > Baptiste Lepilleur wrote:
> > > > >
> > > > > Give a look to class Protector (available since 1.9.10). It allow
> > > > > interception of non STL exception. Check the implementation of the
> > > > > DefaultProtector for an example of usage.
> > > >
> > > > This looks good except that I'm using a TextTestRunner and it hides
> > > > TestRunner::run( Protector* ).
> > > >
> > > > Would it hurt anything if a using declaration were used?
> > > >
> > > > Thanks,
> > > > Noel
> > > > --
> > > > NOTICE: If received in error, please destroy and notify sender.
> Sender
> > > > does not waive confidentiality or privilege, and use is prohibited.
> > > >
> >
> > --
> > NOTICE: If received in error, please destroy and notify sender. Sender
> > does not waive confidentiality or privilege, and use is prohibited.
> >
--
NOTICE: If received in error, please destroy and notify sender. Sender
does not waive confidentiality or privilege, and use is prohibited.
|