반응형
1. pom.xml 설정
1) Junit 4.12 버전 이상
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
2) Spring-boot starter-test
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.5.3.RELEASE</version>
</dependency>
테스트 클래스 구성
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
/**
* Created by stacks5978 on 2017-05-19.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
public class PoolTest {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void test() throws Exception {
logger.info("Tested");
}
}
그냥 어노테이션만 명시해도 테스트가 가능하다(Spring boot인 경우)
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
/**
* Created by stacks5978 on 2017-05-19.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class PoolTest {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void test() throws Exception {
logger.info("Tested");
}
}
반응형
'Development > Java' 카테고리의 다른 글
[Framework] Light4J(light-java) (0) | 2017.05.28 |
---|---|
[JAVA] Object Pooling (0) | 2017.05.19 |
[logger] Logback xml 설정 및 디펜던시 설정 (0) | 2017.05.19 |
[DB] DBCP 구현 - DB Connection Pooling (0) | 2017.05.16 |
[Springboot] JPA(Hibernate) 공부 편 (0) | 2017.04.09 |