I have the following test class:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/application-context.xml" })
public class TestSanity {
@Test
public void testSanity() {
new AnotherTestClass().simpleTest();
}
}
Problem is AnotherTestClass autowire fields are all null (the spring context didnt load). here is AnotherTestClass :
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/application-context.xml" })
public class AnotherTestClass {
@Autowired
private PlayerService playerService;
@Autowired
private IPlayerSessionService playerSessionService;
@Autowired
private PlayerRepository playerRepository;
@Test
public void simpleTest() {
...
}
@Test
public void complexAndLongTest() {
...
}
Thing is both tests in AnotherTestClass runs perfectly when i test. How can i make the autowire fields to get injected?
Thanks