Bug 40682 - Since 2006-09-29 the junit task fails for junit 4 and junit4.1
Summary: Since 2006-09-29 the junit task fails for junit 4 and junit4.1
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.7.0Beta2
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-04 14:23 UTC by Jan Cumps
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments
example ant project exposing the bug (1.57 KB, application/octet-stream)
2006-10-05 07:55 UTC, Jan Cumps
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Cumps 2006-10-04 14:23:54 UTC
Since this nights svn checkout (4-OCT-2006), junit 4-style tests fail.

    [junit] No runnable methods
    [junit] java.lang.Exception: No runnable methods

Tested from fresh svn build on Windows XP and Linux, both running java 1.5.0_06
Comment 1 Jan Cumps 2006-10-04 15:07:06 UTC
Checking when it started failing.
I've got a successful run with a checkout of  --revision '{2006-09-15}'
Now proceeding...
Comment 2 Jan Cumps 2006-10-04 15:23:46 UTC
ok for --revision '{2006-09-20}'
ok for --revision '{2006-09-25}'
ok for --revision '{2006-09-26}'
ok for --revision '{2006-09-27}'
ok for --revision '{2006-09-28}' (revision 450591)

not ok for --revision '{2006-09-29}' (revision 451034)

So, the bug must be introducedin one of these files:

C:\sandbox_ant\ant>svn checkout --revision '{2006-09-29}' 
http://svn.apache.org/
repos/asf/ant/core/trunk/ ant-trunk
U    ant-trunk/src/tests/antunit/types/conditions/matches-test.xml
A    ant-trunk/src/tests/antunit/types/resources/tokens-test.xml
A    ant-trunk/src/tests/antunit/types/resources/utf-16.in
U    ant-trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java
U    ant-
trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest
.java
U    ant-trunk/src/main/org/apache/tools/ant/AntClassLoader.java
U    ant-trunk/src/main/org/apache/tools/ant/UnknownElement.java
U    ant-trunk/src/main/org/apache/tools/ant/filters/TokenFilter.java
U    ant-trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
U    ant-
trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.ja
va
U    ant-trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java
U    ant-trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java
U    ant-trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
U    ant-trunk/src/main/org/apache/tools/ant/types/defaults.properties
A    ant-trunk/src/main/org/apache/tools/ant/types/resources/Tokens.java
U    ant-trunk/src/main/org/apache/tools/ant/types/resources/URLResource.java
A    ant-trunk/src/main/org/apache/tools/ant/util/StringTokenizer.java
U    ant-trunk/src/main/org/apache/tools/ant/util/StringUtils.java
A    ant-trunk/src/main/org/apache/tools/ant/util/FileTokenizer.java
U    ant-trunk/src/main/org/apache/tools/ant/util/Tokenizer.java
U    ant-
trunk/src/main/org/apache/tools/ant/util/ConcatResourceInputStream.java

U    ant-trunk/docs/manual/CoreTypes/resources.html
U    ant-trunk/CONTRIBUTORS
U    ant-trunk/contributors.xml
U    ant-trunk/WHATSNEW
Checked out revision 451034.
Comment 3 Jan Cumps 2006-10-04 23:50:44 UTC
Closing the issue, as I can't replicate it with a completely fresh checkout of 
the trunk.

I did a complete fresh checkout today of revision 453112.
Built it from scratch.
Pointed my ANT_HOME and PATH to it.
The issue does not re-occur.
Comment 4 Jan Cumps 2006-10-05 01:23:02 UTC
I have more background on this.

Before 2006-09-29, junit task worked with junit4 jar in ./lib or CLASSPATH
Since 2006-09-29, junit task fails with junit4 jar in ./lib or CLASSPATH, and 
succeeds when junit 4 jar is not in ./lib or CLASSPATH.
Comment 5 Antoine Levy-Lambert 2006-10-05 04:37:54 UTC
Hello Jan,

From what you wrote, it looks like this issue is a classloading issue.

Peter Reilly changed AntClassLoader.java again yesterday.

He had changed AntClassLoader.java on Wed Sep 27 22:46:57 2006 UTC, revision 450614.

Could you update again your SVN sandbox, I suspect this usecase will work again now.

Regards,

Antoine
Comment 6 Peter Reilly 2006-10-05 04:48:42 UTC
It would be nice to have a test for this.
A small project with a simple test, and a small
build file.
Comment 7 Jan Cumps 2006-10-05 05:56:46 UTC
Reply to Comment #5

Clean build ANT from svn...
Same behaviour as reported in Comment #4

junit task fails with junit4 jar in ./lib or CLASSPATH,
with or without junit4 jar in the classpath of ant's junit task.

junit task succeeds when 
- junit 4 jar is not in ./lib or CLASSPATH, *AND*
- the classpath in the junit task includes the junit4 jar

Reply to Comment #6
Working on that.
Comment 8 Jan Cumps 2006-10-05 07:55:00 UTC
Created attachment 18965 [details]
example ant project exposing the bug

1. Extract the attached zipped project.
2. edit build.properties to reflect the location of junit4 jar file.

-------------------------------------------------------------------

clear junit4 from your classpath, remove junit 4 jar from ant/lib,
if applicable.

run the project
> ant all

=> Success

-------------------------------------------------------------------

put junit4 jar in classpath, or in ant/lib

run the project
> ant all

=> error
Comment 9 Peter Reilly 2006-10-05 09:24:28 UTC
Thanks for the test case - it was a *big* help.
I have tracked down the problem.
The problem is due to
http://issues.apache.org/bugzilla/show_bug.cgi?id=40682
(Order of addX and addConfiguredX), the order
of setting attributes and elements was changed from

addX
setY
addConfiguredZ
execute()

to

setY
addX, addConfiguredZ (in order of the build file)
execute()

However junittask depends on the first order.
It is easy to fix JUnitTask for this, (I will
apply patch when I reach my svn machine), however
 1) I wonder if we need to rollback 40621
 2) why does junit only work for fork="yes" for junit4?

Comment 10 Peter Reilly 2006-10-05 13:14:36 UTC
I have committed a fix for this.
Thanks again for the report and help in tracking the problem.
Comment 11 Jan Cumps 2006-10-05 13:30:46 UTC
Verified from fresh checkout...
It's fixed. Thank you.