1

I have a junit test class with following annotations :

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:custom-context.xml")

There exists a class in another context that is required in my test that is autowired so I require this context to be loaded. How can this be implemented ?

I've tried :

@ContextConfiguration("classpath:custom-context.xml , classpath:custom-context2.xml")

But this does now work as it does not seem to load multiple contexts using the , delimiter.

1

2 Answers 2

3

Also can use widcard like this:

@ContextConfiguration({"classpath:custom-*.xml" })
Sign up to request clarification or add additional context in comments.

Comments

2

Use an array of strings, like :

@ContextConfiguration(locations={ "classpath:custom-context.xml" , "classpath:custom-context2.xml" })

from spring api doc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.