ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: "No runnable method" exception during junit task with SVN HEAD and JUnit 4.
Date Thu, 23 Mar 2006 10:54:43 GMT
Bill Barker wrote:
> "Curt Arnold" <carnold@apache.org> wrote in message 
> news:7749E7D7-EE51-49CC-9137-63206A9433E3@apache.org...
>> On Mar 20, 2006, at 12:39 PM, Jesse Glick wrote:
>>
>>> Curt Arnold wrote:
>>>>> when Ant auto-detects JUnit-4, it doesn't look for the static
>>>>> suite()  method, and just assumes that you've defined all of your
>>>>> tests with Annotations.
>>>> I've searched my dev@ant.apache.org mailing list and Bugzilla and
>>>> could not find this particular issue being raised.  Is this a known
>>>> issue, is there an associated bug [...]
>>> Don't believe it's a known issue. Could be a bug in either junit4  or 
>>> Ant - junit4 is supposed to know about suite(), I guess.
>>>
>>> -J.
>>
>> The test works fine with Ant 1.6.5 and the gump build of junit4.  The 
>> junit-dev team was not aware of the problem and did not have any  changes 
>> at the time of the failure that seemed to be related to the  issue. 
>> Points strongly at something in the Ant changes around 10- Mar-2006, 
>> though I did not investigate further since it seemed to be  a known issue 
>> to Bill Barker.
>>
> 
> Yup, it's a known issue.  From JUnitTestRunner.java(line 293):
>                 if (junit4) {
>                     // Let's use it!
>                     suite = (Test) junit4TestAdapterClass.getConstructor(new 
> Class[] {Class.class}).
>                             newInstance(new Object[] {testClass});
>                 } else {
>                     // Use JUnit 3.
> 
>                     Method suiteMethod = null;
>                     try {
>                         // check if there is a suite method
>                         suiteMethod = testClass.getMethod("suite", new 
> Class[0]);
>                     } catch (NoSuchMethodException e) {
>                         // no appropriate suite method found. We don't 
> report any
>                         // error here since it might be perfectly normal.
>                     }
>                     if (suiteMethod != null) {
>                         // if there is a suite method available, then try
>                         // to extract the suite from it. If there is an 
> error
>                         // here it will be caught below and reported.
>                         suite = (Test) suiteMethod.invoke(null, new 
> Class[0]);
> 
> The junit4 class doesn't know or care if there is a 'static Test suite()' 
> method on the class.  It looks for Annotations, and then falls back on 
> pattern matching method names.  It seems that the suite() method has always 
> been an Ant thing.


Test suites run in GUI/IDE junit runner too, I use it to generate test 
cases from document manifests, running one test per doc:


public class Suite_01_ExtendsTest extends TestCase {

     /**
      * This is the suite
      *
      * @return
      */
     public static TestSuite suite() {
         return 
SingleDocumentTestCase.createSuite(Suite_01_ExtendsTest.class,
                 CddlmConstants.TEST_PACKAGE_CDL_SET_01,
                 new CdlSmartFrogProcessorFactory());
     }

}



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message