How to create TestContext for Spring Test?
- by HDave
Newcomer to Spring here, so pardon me if this is a stupid question.
I have a relatively small Java library that implements a few dozen beans (no database or GUI). I have created a Spring Bean configuration file that other Java projects use to inject my beans into their stuff.
I am now for the first time trying to use Spring Test to inject some of these beans into my junit test classes (rather than simply instantiating them).
I am doing this partly to learn Spring Test and partly to force the tests to use the same bean configuration file I provide for others.
In the Spring documentation is says I need to create an application context using the "TestContext" class that comes with Spring. I believe this should be done in a spring XML file that I reference via the @ContextConfiguration annotation on my test class.
@ContextConfiguration({"/test-applicationContext.xml"})
However, there is no hint as to what to put in the file!
When I go to run my tests from within Eclipse it errors out saying "failed to load Application Context"....of course.