■ 샘플소스
import static org.junit.Assert.assertNotNull ; import static org.junit.Assert.assertTrue ; import static org.junit.Assert.fail ; import java.util.List; import org.apache.log4j.Logger; import org.junit.After; import org.junit.Before; import org.junit.Ignore; 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 org.springframework.test.context.web.WebAppConfiguration; import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={ "classpath:/junit_test/datasource-config.xml" , "classpath:/junit_test/root-context.xml" }) @WebAppConfiguration public class SchedulerServiceTest { private Logger logger = Logger.getLogger (this .getClass()); private Object obj = null; @Autowired private SampleService sampleService; @Before public void setUp() { logger.debug( "각 테스트가 시작되기 전에 실행된다." ); } @After public void shutDown() { logger.debug( "각 테스트가 끝난 후에 실행된다." ); } @Test public void testList_리스트_조회() { List<Object> list = sampleService.list(); logger.debug( "[mirinae.maru] list size : " + list .size() ); assertNotNull( list ); } @Ignore public void testUpdateData() { fail("Not yet implemented"); } @Test @Transactional public void testDeleteData_데이터_삭제_테스트() { Object obj = new Object(); int result = sampleService.deleteData(obj); assertTrue( result>0 ); } }
- spring mybatis mysql 연결 예제 2018년 5월 4일
- apache commons StringUtils 예제 2018년 5월 3일
- java string 변수 switch, junit test 2018년 2월 12일
- 단정문 assertEquals와 assertSame의 차이점 2017년 4월 12일
- spring service junit test 2016년 5월 25일
- mybatis mapper junit test 2016년 5월 2일
- JUnit Controller Test java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfig 2016년 3월 22일
- java eclipse static import 2016년 3월 15일
- junit 단정문 – Assertions 2016년 3월 14일
- junit & spring-test maven dependency 2016년 3월 14일