How to create TestContext for Spring Test?

Posted by HDave on Stack Overflow See other posts from Stack Overflow or by HDave
Published on 2010-05-19T04:39:28Z Indexed on 2010/05/19 4:50 UTC
Read the original article Hit count: 284

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about spring

Related posts about test