File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant + JUnit integration problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant + JUnit integration problem" Watch "Ant + JUnit integration problem" New topic
Author

Ant + JUnit integration problem

jeff wisgo
Greenhorn

Joined: Apr 20, 2004
Posts: 15
I am able to run JUnit tests through a simple batch file as below:



However, when I have the following block in my ANT build.xml file, I get a strange error:



The error is:


Testsuite: rov.test.AllTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

Caused an ERROR
Class org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner can not access a member of class rov.test.AllTest with modifiers "public static" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)


I can't figure out whats wrong with my ANT file, does anyone have any suggestions? Thanks in advance.

[ edited long unbroken classpath and changed error message with long unbroken line from a code block to a quote block -ds ]
[ September 23, 2004: Message edited by: Dirk Schreckmann ]
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Caused an ERRORClass org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner can not access a member of class rov.test.AllTest with modifiers "public static" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)


you should be fixed in line of

public static type someVariable ; to

public type someVariable




And for more information to solve this problem, please post your code.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Notice that the junit task doesn't run the main method of your class, but is searching for a suite method instead, as far as I know.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
jeff wisgo
Greenhorn

Joined: Apr 20, 2004
Posts: 15
Here is my code:

Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Try making your AllTests class extend junit.framework.TestCase


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Try making your AllTests class public! The TestRunner is in a different package, after all. (No need to extend TestCase, I'd suspect.)
jeff wisgo
Greenhorn

Joined: Apr 20, 2004
Posts: 15
The problem was I needed to add public to the class declaration.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant + JUnit integration problem