spring에서 testCase를 작성해보자.
junit4 annotation 종류
- @After
테스트시 매번 실행 후 호출되는 메소드 - @AfterClass
모든 테스트 후 한번 호출되는 메소드 - @Before
테스트시 매번 실행 전 호출되는 메소드 - @BeforeClass
모든 테스트 전 한번 호출되는 메소드 - @Ignore
skip되는 테스트 메소드 - @Test
테스트 메소드
exemple (spring 연동)
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.sec.ams.controller.apk.TotalApkContoller;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:springmvc-servlet.xml" })
public class ApkServiceTest {
@Autowired
TotalApkContoller totalApkContoller;
@Test
public void test() {
String totalView = totalApkContoller.getTotalView();
assertEquals("apk/total", totalView);
// fail("Not yet implemented");
}
}
ref:
'program language > java' 카테고리의 다른 글
static map 사용 관련.static field initialzation (0) | 2012.07.15 |
---|---|
log4j 설정 (1) | 2012.04.09 |
JAX-RS: Java API for RESTful Web Services (0) | 2012.03.26 |
JDO(Java Data Object) (0) | 2012.03.15 |
JSR(Java Specification Requests),JCP(Java Community Process) (1) | 2012.03.06 |