Adam, On Mon, 2008-10-06 at 06:24 +1100, Adam Murdoch wrote: > > Russel Winder wrote: > > I have a class in my test hierarchy that is a support class for the > > tests, it has no tests in itself. Gant, Maven, Ant, SCons are OK with > > this, but Gradle is flagging this as a test failure: it seems Gradle > > asserts that all classes in the test hierarchy must have one or more > > test cases. > > > > > > I think this is due to 2 things: > - The test task by default attempts to run every class in the test > hierarchy as a junit test class, and
Hummm... on reflection (!) I guess this is a reasonable default. On
the other hand Eclipse and IntelliJ IDEA don't seem to suffer this
problem, they must reflect on the classes presented and not process
those that are not subclasses of TestCase.
> - Junit asserts that every class it is given has some test cases in it.
Is this true? I am not convinced (but am open to being :-) As far as I
am aware you don't get an assertion failure for a TestCase with no test
methods -- at least not using Groovy, in Java I always use TestNG not
the inferior :-) JUnit.
> You can change which classes are treated as test classes using the test
> task's include() and exclude() methods:
>
> test {
> include '**/*.Test.class'
> exclude '**/Abstract*'
> }
I added the line:
test {
include ( '**/*Test.class' )
}
and all the spurious problems went away. Gradle gives a test fail that
doesn't happen with Ant or Gant but I think that is a very different
problem.
> Having the test task run everything is not a particularly good default.
> We should pick a convention for test class naming, use it as the
> default, and allow you override the convention if you care. We could
> possibly also filter out classes which aren't test classes (eg abstract
> classes), regardless of the naming scheme we choose.
I think perhaps all classes with a $ or closure in the name should be
ignored since these are generated during compilation (anonymous classes,
closures, etc.) and are highly unlikely to be user test case classes.
> > I am proposing to flag this as a bug and create a JIRA, but thought I
> > ought to check first.
> >
> >
>
> I think you should add something to JIRA. Stuff should just work without
> configuration (or fail with a reasonable error message), and this is not
> the case here.
OK, I'll put something together later this morning.
--
Russel.
====================================================
Dr Russel Winder Partner
Concertant LLP t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road, f: +44 8700 516 084
London SW11 1EN, UK. m: +44 7770 465 077
signature.asc
Description: This is a digitally signed message part
