Skip to content

Instantly share code, notes, and snippets.

@ihoneymon
Created September 20, 2017 01:18
Show Gist options
  • Save ihoneymon/1f630e7f22a8a25342813013d78747b4 to your computer and use it in GitHub Desktop.
Save ihoneymon/1f630e7f22a8a25342813013d78747b4 to your computer and use it in GitHub Desktop.
@before, @after 를 제대로 활용하지 못해서 슬퍼...
import com.wirebarley.webservice.domain.Tx;
import com.wirebarley.webservice.domain.User;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runners.Parameterized;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
public class TestTemplate {
/**
* 단위테스트 시작 전 공통적으로 초기화되는 코드
* - {@link User}나 {{@link Tx}} 엔티티를 생성하고 기본 정보를 등록한다 등의 작업 진행
*
* @throws Exception
*/
@Before
public void setUp() throws Exception {
}
/**
* 단위테스트 종료 후 공통적으로 적용될 로직
* - {@link User}나 {{@link Tx}} 엔티티를 생성하고 기본 정보를 소거하는 등의 작업 진행
* - {@link Transactional}이 걸려있다면 엔티티는 신경안써도 되겠지만
* - {@link org.springframework.test.context.jdbc.Sql} 등을 사용한 경우에는 이에 대한 초기화 용도로 사용
*
* @throws Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* 이건 말 안해도 알겠죵?
* 단위테스트 기본단위
*
* @throws Exception
*/
@Test
public void name() throws Exception {
}
/**
* <a href="https://github.com/junit-team/junit4/wiki/Parameterized-tests">Parameterized tests</a>
* @return
*/
@Parameterized.Parameters
public static Collection<Object[]> data() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment