Hi Steven, I had a sort of similar problem. Maven expects certain things from the unit tests, that eclipse doesn't, the reason being that surefire uses reflection to lance the unit tests. One thing is that all classes are required to have public constructors with either no-arg or String name. There are probably also requirements on public methods. Try making any method that is not a test method private and check your ctors. I am not sure if this is documented anywhere...
Nicole On 06/02/2008, JavaGeek <[EMAIL PROTECTED]> wrote: > > > Hello All, > I have a maven project with JUnit 4.0 unit tests. Most of our unit tests > are failing in Surefire with the message pasted below. However, all of > the > unit tests work when launched from eclipse. Does anyone have any ideas on > how to troubleshoot? > > Thanks in Advance, > Steven > > > java.lang.NoClassDefFoundError > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java > :39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke( > DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at > org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod( > BeforeAndAfterRunner.java:74) > at > org.junit.internal.runners.BeforeAndAfterRunner.runBefores( > BeforeAndAfterRunner.java:50) > at > org.junit.internal.runners.BeforeAndAfterRunner.runProtected( > BeforeAndAfterRunner.java:33) > at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) > at > org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java > :62) > at > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet( > AbstractDirectoryTestSuite.java:138) > at > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute( > AbstractDirectoryTestSuite.java:125) > at org.apache.maven.surefire.Surefire.run(Surefire.java:132) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java > :39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke( > DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at > org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess( > SurefireBooter.java:290) > at > org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java > :818) > > -- > View this message in context: > http://www.nabble.com/tests-throw-java.lang.NoClassDefFoundError-for-MVN%2C-JUnit-4-but-not-eclipse-tp15309895s177p15309895.html > Sent from the Maven - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >