Improve error stack trace when the error comes from the user's test code
------------------------------------------------------------------------

         Key: MSUREFIRE-87
         URL: http://jira.codehaus.org/browse/MSUREFIRE-87
     Project: Maven 2.x Surefire Plugin
        Type: Improvement

    Versions: 2.1.3    
    Reporter: Vincent Massol


For example here's what's printed when my test code reports an error:

{noformat}
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at 
org.apache.maven.surefire.SurefireBooter.main(SurefireBooter.java:785)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at 
org.apache.maven.surefire.SurefireUtils.instantiateBattery(SurefireUtils.java:54)
        at 
org.apache.maven.surefire.Surefire.instantiateBatteries(Surefire.java:262)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:93)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:87)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:63)
        ... 5 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at 
org.apache.maven.surefire.battery.JUnitBattery.processTestClass(JUnitBattery.java:130)
        at 
org.apache.maven.surefire.battery.JUnitBattery.<init>(JUnitBattery.java:69)
        ... 14 more
Caused by: java.lang.RuntimeException: System property "cargo.containers" must 
be defined.
        at 
org.codehaus.cargo.sample.java.AbstractCargoTestCase.addContainerToTest(AbstractCargoTestCase.java:157)
{noformat}

This is really not nice and hard to read as the real cause it buried down the 
stack trace. I would like surefire code to directly make the user's error be at 
the top of the thrown stack trace, i.e. surefire should not catch user 
exceptions. This is what I would expect to see:

{noformat}
 java.lang.RuntimeException: System property "cargo.containers" must be defined.
        at 
org.codehaus.cargo.sample.java.AbstractCargoTestCase.addContainerToTest(AbstractCargoTestCase.java:157)
{noformat}

Thanks

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to