@Alexander,
Hi sir, that's really what I want, you given me a very powerful support !
thanks again from my heart, thank you so ..... much !!!!!!!

On Fri, Aug 31, 2012 at 8:29 PM, Alexander Kriegisch-2 [via AspectJ] <
ml-node+s2085585n4650510...@n4.nabble.com> wrote:

> Like this?
>
> ##### some JUnit 4 tests #####
>
> package de.scrum_master.aop.demo;
>
> import static org.junit.Assert.*;
> import org.junit.Test;
>
> public class MyTestCase {
>     @Test public void testOne() {
>         assertEquals("scrum-master.de", "scrum-" + "master" + ".de");
>     }
>
>     @Test public void testTwo() {
>         throw new RuntimeException("Unexpected test exception");
>     }
>
>     @Test public void testThree() {
>         fail("Not yet implemented");
>     }
>
>     @Test public void testFour() {
>         throw new RuntimeException("Another unexpected test exception");
>     }
> }
>
> ##### an aspect taking care of exception logging #####
>
> package de.scrum_master.aop.demo;
>
> import org.junit.Test;
>
> public aspect TestExceptionHandler {
>     protected void captureThrowable(Throwable t) {
>         System.err.println(t);
>     }
>
>     after() throwing (Throwable t) : execution(@Test * *(..)) {
>         captureThrowable(t);
>     }
> }
>
> I am not catching the exceptions, just logging them, so as to make your
> tests fail as expected for unexpected exceptions. The output looks like
> this:
>
> > java.lang.RuntimeException: Unexpected test exception
> > java.lang.AssertionError: Not yet implemented
> > java.lang.RuntimeException: Another unexpected test exception
>
>
>
> xianglong, 31.08.2012 08:49:
>
> > @Alexander option c is my concern
> >
> >> Yes, I think I can help you if you tell me (in prose, not in code)
> >> what you want to achieve: Do you want to
> >>
> >> a) intercept and log the exceptions in your production code, then
> >> pass them through (i.e. let them happen)?
> >>
> >> b) intercept and log the exceptions in your production code, but
> >> *not* pass them through (i.e. catch them)?
> >>
> >> c) just avoid code duplication with try/catch blocks in your test
> >> cases?
> >>
> >> d) anything else?
> _______________________________________________
> aspectj-users mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4650510&i=0>
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://aspectj.2085585.n4.nabble.com/can-anyone-help-me-to-take-a-look-my-exceptionhandler-tp4650503p4650510.html
>  To unsubscribe from can anyone help me to take a look my exceptionhandler
> ?, click 
> here<http://aspectj.2085585.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4650503&code=bXhsNDE4NUBnbWFpbC5jb218NDY1MDUwM3wzODI5MDIxOTI=>
> .
> NAML<http://aspectj.2085585.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://aspectj.2085585.n4.nabble.com/can-anyone-help-me-to-take-a-look-my-exceptionhandler-tp4650503p4650512.html
Sent from the AspectJ - users mailing list archive at Nabble.com.
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to