Unit tests can't see project classes.

2 views
Skip to first unread message

Stuart Grimshaw

unread,
Apr 21, 2010, 9:47:24 AM4/21/10
to Sheffield Java User Group
I'm trying to convert an ant based project to Maven, I've moved all
the source and tests into the standard Maven structure, and the whole
project compiles fine, however when it comes to run the tests, I get

1
-------------------------------------------------------------------------------
2 Test set: net.plus.adaptors.valueobject.TestProblemState
3
-------------------------------------------------------------------------------
4 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
0.009 sec <<< FAILURE!
5 testProblemState(net.plus.adaptors.valueobject.TestProblemState)
Time elapsed: 0.002 sec <<< ERROR!
6 java.lang.NoClassDefFoundError: Could not initialize class
net.plus.adaptors.valueobject.ProblemState
7 at
net.plus.adaptors.valueobject.TestProblemState.setUp(TestProblemState.java:
17)
8 at junit.framework.TestCase.runBare(TestCase.java:132)
9 at junit.framework.TestResult$1.protect(TestResult.java:110)
10 at junit.framework.TestResult.runProtected(TestResult.java:
128)
11 at junit.framework.TestResult.run(TestResult.java:113)
12 at junit.framework.TestCase.run(TestCase.java:124)
13 at junit.framework.TestSuite.runTest(TestSuite.java:232)
14 at junit.framework.TestSuite.run(TestSuite.java:227)
15 at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:
83)
16 at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:
62)
17 at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:
140)
18 at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
127)
19 at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
20 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
21 at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
22 at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
23 at java.lang.reflect.Method.invoke(Method.java:597)
24 at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:
345)
25 at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:
1009)

net.plus.adaptors.valueobject.ProblemState is a class defined in this
project, so it's not like I've missed a dependancy, debug with -X
shows that both the normal & test classes are on the class path.

The pom file looks like this: http://pastie.org/927728
and the test class looks like this: http://pastie.org/private/klacp1kav5zphcv8ked9a

Any ideas?


--
Subscription settings: http://groups.google.com/group/java-sheffield/subscribe?hl=en

Ian Ibbotson

unread,
Apr 21, 2010, 9:57:46 AM4/21/10
to java-sh...@googlegroups.com
Very strange :S

can we have ProblemState too? Can't see anything obvious.....

e
--
Ian Ibbotson
Director
Knowledge Integration Ltd
35 Paradise Street, Sheffield. S3 8PZ
T: 0114 273 8271
M: 07968 794 630
W: http://www.k-int.com

Stuart Grimshaw

unread,
Apr 21, 2010, 10:02:30 AM4/21/10
to java-sh...@googlegroups.com
http://pastie.org/private/tuxztrkv7kq9cianckra

Nothing special, a class auto-created from a WSDL file.

-S

Follow me on Twitter: http://twitter.com/stubbs
Blog: http://stubblog.wordpress.com
My art: http://stuartgrimshaw.imagekind.com
Stock Images: http://en.fotolia.com/partner/16775

Ian Ibbotson

unread,
Apr 21, 2010, 10:05:12 AM4/21/10
to java-sh...@googlegroups.com
Arse.. that disposes with the obvious problem... -X output?

Stuart Grimshaw

unread,
Apr 21, 2010, 10:20:47 AM4/21/10
to java-sh...@googlegroups.com
Nothing too exciting, I've produced it for the single test.
x-debug.txt.gz

James Jefferies

unread,
Apr 21, 2010, 10:41:07 AM4/21/10
to Sheffield Java User Group
Argh, trying to get it to compile, but it's trying to access
javax.xml.rpc.encoding.Deserializer from rt.jar for some reason... and
it can't - I think I've had this before with licensing rt.jar stuff
and I can't remember how to fix it!

Stuart Grimshaw

unread,
Apr 23, 2010, 6:06:39 AM4/23/10
to java-sh...@googlegroups.com
Did you get it to compile James?

You might needs the deps from the parent.pom, which I can give you in you want.
Reply all
Reply to author
Forward
0 new messages