[ http://jira.codehaus.org/browse/SUREFIRE-44?page=comments#action_66951 ] 

Ken Arnold commented on SUREFIRE-44:
------------------------------------

My mistake, this is not a 2.0 issue (that was a typo).  It's a 1.5.3 issue.

I am going to have to add no-arg constructors to all nested classes right now.  
This is just wrong.

> Inner class inclusion too powerful
> ----------------------------------
>
>          Key: SUREFIRE-44
>          URL: http://jira.codehaus.org/browse/SUREFIRE-44
>      Project: surefire
>         Type: Bug

>     Versions: 2.0
>     Reporter: Ken Arnold

>
>
> When inner classes were included, it was done in a way that was too powerful. 
>  I believe it is too powerful in the following ways:
>     It is not name based -- it assumes that all inner classes of an included 
> class are test cases.
>     It does not work on nested classes (non-static classes)
> See the test case and stack trace below.
> I know people put tests in nested classes, but many nested classes exist for 
> other reasons (simple mock objects, for example).  Inner classes do not have 
> no-arg constructors, and so including them includes classes that pretty much 
> by definition will not be runnable.
> As things stand, I cannot put a nested (non-static inner) class in a test 
> case.  I will get the exception below.
> There needs to be some marker for nested test classes.  If nothing else, 
> nested classes without a no-arg constructor should be ignored.  
> But that still makes the inclusion very broad.  The default inclusion of 
> top-level classes is much more selective.  I would prefer if the default 
> inclusion of nested classes followed the same default naming pattern.  But at 
> the very least, please ignore classes without  no-arg constructors.
> I have been puzzling myself over errors like the following:
> java.lang.NoSuchMethodException: 
> com.hyphenhealth.edc.drq.editchecks.queries.compute.TestAThing$Foo.<init>()
>         at java.lang.Class.getConstructor0(Class.java:2647)
>         at java.lang.Class.getConstructor(Class.java:1629)
>         at 
> org.apache.maven.surefire.battery.JUnitBattery.getTestConstructor(JUnitBattery.java:307)
>         at 
> org.apache.maven.surefire.battery.JUnitBattery.processTestClass(JUnitBattery.java:150)
>         at 
> org.apache.maven.surefire.battery.JUnitBattery.<init>(JUnitBattery.java:81)
>         at 
> org.apache.maven.surefire.SurefireUtils.instantiateBattery(SurefireUtils.java:63)
>         at 
> org.apache.maven.surefire.Surefire.instantiateBatteries(Surefire.java:262)
>         at org.apache.maven.surefire.Surefire.run(Surefire.java:140)
>         at org.apache.maven.surefire.Surefire.run(Surefire.java:87)
>         at org.apache.maven.surefire.Surefire.run(Surefire.java:63)
>         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:585)
>         at 
> org.apache.maven.surefire.SurefireBooter.main(SurefireBooter.java:785)
> RUN ABORTED
> java.lang.NoSuchMethodException
> Test code:
> public class TestAThing {
>     public class Foo { }
> }

-- 
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