You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Brett Porter (JIRA)" <ji...@codehaus.org> on 2007/02/23 08:06:39 UTC

[jira] Updated: (SUREFIRE-44) Inner class inclusion too powerful

     [ http://jira.codehaus.org/browse/SUREFIRE-44?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brett Porter updated SUREFIRE-44:
---------------------------------

    Fix Version/s:     (was: 2.3)
                   2.4

> Inner class inclusion too powerful
> ----------------------------------
>
>                 Key: SUREFIRE-44
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-44
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 2.0 (2.2 plugin)
>            Reporter: Ken Arnold
>             Fix For: 2.4
>
>
> 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