开发者

javadoc cannot find org.junit.Test

When I run javadoc on my java source code, I get this error for th Junit test class:

[javadoc] /mypath/TestStuff.class: warning: Cannot find annotation method 'expected()' in type 'org.junit.Test': class file for org.junit.Test not found

The problem appears with junit version 4 with this type of annotation:

@Test(expected=Exception.class)

Obvisouly, it sounds like javadoc cannot find org.junit.Test but why would it need it in the 1st place ? How do I fix that ?

Cheers David


UPDATE:

the junit jar is not on my project classpath but is in $ANT_HOME/lib. This way, I don't have to add it to my project lib folder and the junit ant target works fine.

It sounds like the javadoc开发者_StackOverflow target in ant doesn't use the $ANT_HOME/lib to look for jars


org.junit.Test is the class defining the @Test annotation that you're using. Sounds like you need to add the junit jar to the classpath.

EDIT: I set up projects with ant to use 2 classpaths, one for regular classes and one for test-only stuff, and I add junit to the test-only classpath.


You need to tell the javadoc task in Ant where to find junit, using "classpath", or "classpathref" attributes or a nested <classpath> element.

Something like

 <javadoc ...>
     ...
     <classpath path="path/to/your/junit.jar"/>
     <!-- or maybe "${env.ANT_HOME}/lib/junit.jar" ? -->
 </javadoc>

See http://ant.apache.org/manual/Tasks/javadoc.html for reference.

It might mean that you'll have to store junit.jar in the project, since it's easier to reference that way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜