
Originally Posted by
jgaines
In the manifest I was importing org.springframework.test. This pulled the jar onto the classpath, which made all its classes visible in Eclipse. But because I was only importing that package, and not org.springframework.test.context.junit4, I wasn't supposed to be able to see the SpringJUnit4ClassRunner. Eclipse reports this as an access restriction error, rather than a class not found exception or no class def error.
So the solution was simple - just import the specific, correct packages. (I should add that I started the project with automated manifest generation, but turned that off after a while as I was finding it difficult to understand the changes it was making. If I'd left it on, presumably it would have imported the correct packages for me). And leave the Eclipse preference for treating access restrictions as errors alone.
Yeah, that's exactly right. Glad to see that you got to the bottom of it. Apologies for not responding earler and saving you the trouble.
The one thing I'm still not sure about, though, is whether putting the test dependencies into the manifest with optional resolution is the smartest way to express them. If we used Maven, I could put 'em in the pom - but we don't.
What is the Best Way to capture test-only dependencies in an STS project?
You can use a TEST.MF file in your project to describe your test-only dependencies. There's some more information about this in Christian's blog.
Andy Wilkinson
SpringSource