• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Ant + JUnit integration problem

 
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 ]
 
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.
 
author
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:

 
author
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
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.

 
Maybe he went home and went to bed. And took this tiny ad with him:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic