You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Krikor Krumlian <kr...@wgbh.org> on 2005/02/28 15:46:02 UTC

Junit with maven does it work

Hello everyone
  Has anyone been able to make junit tests work in maven ? If yes
can you show me the dependency you used maven version and
the <unitTest> stuff .

It seems so easy and should work but for some reason i have not been
able to .

thank you


Re: Junit with maven does it work

Posted by Krikor Krumlian <it...@wgbh.org>.
Thank you martijn Dashorst

Figured out my mistake and what was happening , the problem was that in 
my unit tests
I have specified the package name  test , So maven  was putting the 
classes in in test-classes/test/Testxxx.class
and thus it was not finding it later when it needed to test. so when 
you have testcases in the /test/ folder
dont' specify package name.

test:test:
  [junit] Running KkTest
  [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
  [junit] Testsuite: KkTest
  [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
  [junit]
  [junit] Null Test: Caused an ERROR
  [junit] KkTest
  [junit] java.lang.ClassNotFoundException: KkTest
  [junit] at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
  [junit] at java.security.AccessController.doPrivileged(Native Method)
  [junit] at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
  [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
  [junit] at 
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
  [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
  [junit] at 
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
  [junit] at java.lang.Class.forName0(Native Method)
  [junit] at java.lang.Class.forName(Class.java:141)
  [junit]

So if you ever recieve this kind of error while trying to unit test , 
make sure package
names are correct.

things learned

Maven -X debug to check classpath and what not

Thank you all , hope you never do this mistake

Re: Junit with maven does it work

Posted by Martijn Dashorst <ma...@dashorst.dds.nl>.
Krikor Krumlian wrote:

> Hello everyone
>  Has anyone been able to make junit tests work in maven ? If yes
> can you show me the dependency you used maven version and
> the <unitTest> stuff .
>
> It seems so easy and should work but for some reason i have not been
> able to .
>
> thank you
>
>
Try the 'maven genapp' plugin, which will provide you with a Java 
project which has all you need to answer your question(s).

Martijn

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Junit with maven does it work

Posted by Krikor Krumlian <kr...@wgbh.org>.
Thank you martijn Dashorst

Figured out my mistake and what was happening , the problem was that in 
my unit tests
I have specified the package name  test , So maven  was putting the 
classes in in test-classes/test/Testxxx.class
and thus it was not finding it later when it needed to test. so when 
you have testcases in the /test/ folder
dont' specify package name.

test:test:
  [junit] Running KkTest
  [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
  [junit] Testsuite: KkTest
  [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
  [junit]
  [junit] Null Test: Caused an ERROR
  [junit] KkTest
  [junit] java.lang.ClassNotFoundException: KkTest
  [junit] at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
  [junit] at java.security.AccessController.doPrivileged(Native Method)
  [junit] at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
  [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
  [junit] at 
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
  [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
  [junit] at 
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
  [junit] at java.lang.Class.forName0(Native Method)
  [junit] at java.lang.Class.forName(Class.java:141)
  [junit]

So if you ever recieve this kind of error while trying to unit test , 
make sure package
names are correct.

things learned

Maven -X debug to check classpath and what not

Thank you all , hope you never do this mistake