• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JUnit TestCollector Error

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have successfully compiled the junit test case class MoneyTestCase



Now, when I try to run it using this command:

java -classpath /usr/share/java/junit.jar junit.swingui.TestRunner MoneyTestCase

I get an error stating:

Class not found "MoneyTestCase"

Nevertheless, MoneyTestCase.class is right there in my working directory.

Now, when I click the drop-down box on the swingui I get this message:

No Test Cases Found.
Check to see the configured 'Test Collector' is supported on this platform.

Has anybody else dealt with this problem?

Thank You for Responding.




 
Andrew Stallard
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem only occurs from the command line. In the IDE it works fine.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try:


The current directory isn't in the classpath in your example.

Also, note that the swingui runner has been removed in JUnit 4.X. At that point, you'll have to use the IDE runner if you want a green bar.
 
Andrew Stallard
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Try:


The current directory isn't in the classpath in your example.

Also, note that the swingui runner has been removed in JUnit 4.X. At that point, you'll have to use the IDE runner if you want a green bar.



Now, I have a different error:

Exception in thread "main" java.lang.NoClassDefFoundError: MoneyTestCase (wrong name: moneyx/MoneyTestCase)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
at junit.runner.TestCaseClassLoader.loadClass(TestCaseClassLoader.java:112)
at junit.runner.ReloadingTestSuiteLoader.load(ReloadingTestSuiteLoader.java:9)
at junit.runner.BaseTestRunner.loadSuiteClass(BaseTestRunner.java:208)
at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:101)
at junit.swingui.TestRunner.runSuite(TestRunner.java:666)
at junit.swingui.TestRunner.start(TestRunner.java:783)
at junit.swingui.TestRunner.main(TestRunner.java:104)

Again, I'm not sure why this happens. The class is right there and the classpath is specified in the java command.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure. Your classpath looks right now.

Is "moneyx" in your code/directory anywhere? It almost looks like the code was compiled as if it were in the moneyx package and now is being run without that.
 
Andrew Stallard
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:I'm not sure. Your classpath looks right now.

Is "moneyx" in your code/directory anywhere? It almost looks like the code was compiled as if it were in the moneyx package and now is being run without that.



It works if I remove the package declarations.

Works from working directory without package declarations:



In addition, I've tried going to the parent directory and compiling and running from there. That didn't work whether I had the package declarations on MoneyTestCase or not.

Does not work at all. (from parent directory):




 
reply
    Bookmark Topic Watch Topic
  • New Topic