• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

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.

 
Your mother was a hamster and your father was a tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!