This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration | |
public class ContextConfigLocationTest { | |
@Test | |
public void test1() { | |
} | |
@Test | |
public void test2() { | |
} | |
} |
@RunWith()
스프링의 테스트 컨텍스트 프레임워크 JUnit 확장 기능 지정
Junit은 각각의 테스트가 서로 영향을 주지 않고 독립적으로 실행됨을 원칙으로 하기에 @Test 마다 오브젝트를 생성한다.
이와 같은 Junit의 특성으로 인하여 ApplicationContext도 매번 새로 생성되기 때문에 테스트가 느려지는 단점이 있다.
그러나 @RunWith 애노테이션은 각각의 테스트 별로 오브젝트가 생성 되더라도 싱글톤의 ApplicationContext를 보장한다.
@RunWith() 대신 AbstractJUnit4SpringContextTests를 상속받아 사용할 수 있음.
@ContextConfiguration()
spring bean 메타 설정 파일의 위치를 지정할 때 사용되는 애노테이션이며 경로를 지정하지 않으면 테스트 클래스 파일이 있는 패키지 내에서 다음의 설정 파일을 사용한다.
ContextConfigLocationTest-context.xml
contextconfiglocationtest-context.xml
대소문자 구분 없음
'프로그래밍' 카테고리의 다른 글
db connection pool 어떤 걸 쓸까? (0) | 2012.12.13 |
---|---|
web.xml url-pattern / 와 /* 의 차이점 (11) | 2012.12.06 |
spring 웹 어플리케이션 기반의 web.xml 설정 정리 (0) | 2012.12.05 |
fail-fast 방식이란? (0) | 2012.11.27 |
화면 입력, 수정, 상세 보기 페이지 개발 방법 (0) | 2012.11.22 |
spring meta annotation 정리 (0) | 2012.11.21 |
HashMap 메소드 테스트 케이스 작성 (0) | 2012.11.09 |
synchronized 키워드 3가지 테스트 케이스 (0) | 2012.11.09 |