본문 바로가기
백엔드/Java

Spring + Mybatis + Junit 단위 테스트

by david100gom 2017. 9. 6.

1. 준비

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!-- 빌드시 test 과정 skip -->
<properties>
    <maven.test.skip>true</maven.test.skip>
</properties>
 
 
<!-- 단위 테스트시 필요한 lib -->
<dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>1.4</version>
    <scope>test</scope>
</dependency>
 
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.35</version>
    <scope>test</scope>
</dependency>
 
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
</dependency>
 
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${spring.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
   <groupId>org.jmock</groupId>
   <artifactId>jmock</artifactId>
   <version>2.8.1</version>
</dependency>
 
cs

2. 테스트용 context 설정파일 생성 

   - sqlSessionFactory 와 dataSource 연결 목적

3. 주의사항

  - javaee-web-api 가 있을 경우 에러가 발생함. (Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation)

 

 

'백엔드 > Java' 카테고리의 다른 글

Spring Data Redis - Jedis vs Lettuce  (0) 2019.08.18
리팩토링  맛보기 1탄  (0) 2019.08.11
JUnit 4.5 에러  (0) 2019.03.13
Spring @Autowired 사용시 주의점  (0) 2019.03.11
PowerMockup  (0) 2013.10.09
인터페이스 활용  (1) 2013.03.06
jstat - JVM 통계 데이터 감시 툴  (1) 2009.08.12
자바 JVM 옵션 리스트  (1) 2009.07.01

댓글