TDD
JUnit Test에서 application context 로딩
skydev
2019. 7. 4. 11:09
package com.test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath:/test-context.xml"
})
public abstract class AbstractApplicationContextTest {
@Autowired
protected ApplicationContext context;
}
ContextConfiguration 에서 classpath로 지정할 수 없는 경우 file로 지정한다.
ex) file:src/webapp/WEB-INF/spring/root-context.xml