KPrince36
KPrince36

Reputation: 2946

What is XML file needed to test for Spring Configuration Errors?

I am testing my configuration file setup. I understand that I need

@ContextConfiguration({"/test-applicationContext.xml"})

and

@RunWith(SpringJUnit4ClassRunner.class)

I also understand that this xml file should be placed in src/test/java/resources. What I can't find is a clear explanation of what exactly goes into this xml file to make the test run. I would just like to run my test which loads my base level config file which is written in src/main/webapp/WEB-INF/web.xml. My base level config file import several other config files. I want to make sure everything is wired up correctly.

Can someone please tell me what goes in the test-applicationContext.xml file?

Upvotes: 0

Views: 86

Answers (1)

Jamie Bisotti
Jamie Bisotti

Reputation: 2685

You don't necessarily need a test-applicationContext.xml file; you would typically only have a file like that if you needed to use an alternate bean for testing (one that did not hit a production system, for instance). You should just need to point @ContextConfiguration to your main application context file(s) and all should be well.

Upvotes: 2

Related Questions