I am working on the Spring Framework. and made one junit class but i am not able to properly load the xml files needed to run the @Test method in junit class. In my case
WEB-INF
test/<package_name>
Please suggest me right way to declare the xml files in
@ContextConfiguration
@ContextConfiguration( locations={ "classpath:/applicationContext.xml",
"classpath:/applicationDatabaseContext.xml" })
Error :
Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@48fa48fa] to prepare test instance [] java.lang.IllegalStateException: Failed to load ApplicationContext
If you are using Maven (recommended) then placing your Spring configuration files in the standard location src/main/resources
(and src/test/resources
for any test-specific configuration), then during the build these files will be copied to the target/classes
directory.
You can reference these in your @ContextConfiguration
with simply:
@ContextConfiguration(locations = { "/applicationContext.xml",
"/applicationContext-test.xml"})
If you're not using Maven, I'd still recommend using the Standard Directory Layout for source and artifacts, and making your (presumably Ant-based) build process work in a similar manner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With