Hi Peter,
On May 9, 2008, at 12:18 AM, Peter Niederwieser wrote:
Hi,
when building a Java project, how does Gradle decide which classes
under
src/test/java are tests (and therefore need to be executed), and
which are
not? (The most elegant solution for JUnit 4 would be to treat a
class as a
test iff it has at least one method annotated with @Test.)
Gradle itself uses 3.8 conventions for its tests (because IntelliJ
did not support JUnit 4 test execution a while ago).
In such a case have to pass a pattern which tests are included to the
test task. The include and exclude pattern are applied to the test-
classes folder.
test {
include '**/*Test.class'
exclude '**/Abstract*'
// We set forkmode to ONCE as our tests are written in Groovy
and the startup time of Groovy is significant.
options.fork(forkMode: ForkMode.ONCE, jvmArgs: ["-ea", "-
Dgradle.home=roadToNowhere"])
}
Right now there is no default pattern for inclusions.
Gradle delegated to the Ant JUnit task which works also with JUnit 4.
I need to figure out if the JUnit Ant task relies on the same
filtering used for 3.8 tests, also for JUnit 4 tests. This would be
inconvenient. As you have said above, with JUnit 4 there is an easy
way to identify a test. What happens if you include all classes when
you have JUnit 4 tests? Does the Ant task throws an exception because
it tries to execute a non JUnit test class?
Cheers,
Peter
PS: Is it possible to disallow posting to the parent forum? I keep
falling
into this trap.
I gonna check if this is possible.
- Hans
--
View this message in context: http://www.nabble.com/How-does-Gradle-
decide-whether-a-class-is-a-test--tp17137707p17137707.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
--
Hans Dockter
Gradle Project lead
http://www.gradle.org