develog

[junit] spring junit 설정1 본문

Dev/junit

[junit] spring junit 설정1

냐옴 2019. 8. 2. 15:48

@ContextConfiguration(locations = {}) 를 사용

TestBase.java

import org.junit.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;
import org.springframework.test.context.web.WebAppConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
    "file:src/test/resources/WEB-INF/spring/root-context.xml",
    "file:src/test/resources/WEB-INF/spring/appServlet/appServlet-context.xml"
})
@WebAppConfiguration
public class TestBase {
    
    @Autowired
    protected ApplicationContext applicationContext;
    
    @Test
    public void test1() {
        System.out.println("test1");
    }

}

'Dev > junit' 카테고리의 다른 글

[junit4] pom.xml  (0) 2019.08.27
[junit] spring junit 설정2  (0) 2019.08.02
[JUnit] JUnit Transaction Rollback  (0) 2015.05.06
JUnit 에서 ApplicationContext 접근  (0) 2013.12.11
[junit] ExtSpringJUnit4ClassRunner  (0) 2013.12.09
Comments