Reputation: 71
This is my JUnit class :
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "WEB-INF/spring-test-config.xml"})
public class TestXXXX extends TestBase
{ ...
When I launch this test class with JUnit runner (from Eclipse), it's failed, because the file spring-test-config.xml
is not found.
My project architecture is :
/src/main/com/xxx/
: my source code
/src/main/WEB-INF/
: my config files; under this folder there is spring-test-config.xml
: this file is not the final xml because it contains some tokens which replace by a Ant target. And the final result of this file is place in WebContent
(deploy directory in fact) - see above.
/WebContent/WEB-INF/classes/com/xxx/
: my binary code
/WebContent/WEB-INF/spring-test-config.xml
So, how can i do to resolve this problem ?
Upvotes: 2
Views: 10675
Reputation: 325
Can you show all your project structure, and where is your test class placed too.
Configure directories in classpath from eclipse.
After that you can define your spring-context application file in src/resources/test
directory and load it with @ContextConfiguration(locations = { "/spring-test-config.xml"})
.
I hope it helps
Upvotes: 5
Reputation: 81
You would probably want to check your ant configuration.
I had the same problem (using Maven) and tried Ricardo's and Katie's ideas no to avail, then I put a test config file into /src/test/resources (note the subtle difference) and only then did '@ContextConfiguration(locations = { "/spring-test-config.xml"})' work. In conclusion, you probably want to go with Ricardo's idea and then check your build process.
Upvotes: 0
Reputation: 1
I've faced this problem before - you need to add the WEB-INF folder to your build path.
Upvotes: 0