classes with no tests in the test hierarchy

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

classes with no tests in the test hierarchy

Russel Winder-2
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 am proposing to flag this as a bug and create a JIRA, but thought I
ought to check first.

Thanks.

--
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 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: classes with no tests in the test hierarchy

Adam Murdoch-2


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
- Junit asserts that every class it is given has some test cases in it.

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*'
}

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


Adam

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: classes with no tests in the test hierarchy

hans_d
Administrator

On Oct 5, 2008, at 9:24 PM, 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
> - Junit asserts that every class it is given has some test cases in  
> it.
>
> 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*'
> }
>
> 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.

That would make a lot of sense. Right now we simply delegate to the  
Ant JUnit task and Gradle simply exposes the limitations of this Ant  
task. When we do the work to integrate TestNG I think that would be a  
good time to write our own test runners and create our own better  
filters. I think the default should be that regardless of the name  
any executable TestCase should be executed.

- Hans

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: classes with no tests in the test hierarchy

helmut.denk
In reply to this post by Adam Murdoch-2
there is already a jira regarding this:
http://jira.codehaus.org/browse/GRADLE-243 

default-pattern should IMO be:

test {
    include '**/*.Test.class'
    include '**/*.Tests.class'
    exclude '**/Abstract*'
}

-> different people want to have different
defaults per gradle-installation ...



Adam Murdoch-2 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
- Junit asserts that every class it is given has some test cases in it.

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*'
}

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


Adam

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: classes with no tests in the test hierarchy

Russel Winder-2
In reply to this post by Adam Murdoch-2
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 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: classes with no tests in the test hierarchy

helmut.denk
In reply to this post by hans_d
hdockter wrote
I think the default should be that regardless of the name  
any executable TestCase should be executed.
yes,  this sounds like a better solution than
the class-name-filter-pattern.

-> increasing the abstraction-level over unit-testing-tools
(junit3, junit4, testng).