Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ant + JUnit integration problem

 
jeff wisgo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jeff wisgo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code:

 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try making your AllTests class extend junit.framework.TestCase
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was I needed to add public to the class declaration.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic