JUnit & Eclipse 201260053 Abbos Shomurodov 201260058 채숭흠 TEAM 1 200711437 성하진 200511355 정용구 200911436 조성완
Contents 1. Software Testing Theory 2. Eclipse Plug-in 3. JUnit Practice
Software Testing Theory 1.1 Importance of testing 1.2 Test Driven Development(TDD) 1.3 Extreme Programming(XP) 1.4 Unit Test 1.5 Structural Test 1.6 JUnit
Importance of Testing 프로그램개발도중, 결함을발견한시기가늦어질수록수정비용이늘어난다. 프로그램의결함유무를점검하면서개발하는, 유동적이며변화에기민한개발방법론이필요 As find problems lately, the cost of modification grows.
Importance of Testing(cont.) Timings of software testing During development After organize the requirements Complete timing of coding 즉, 개발내내반복적으로테스트
Test Driven Development Not a test technique, analysis technique 테스트기법이아닌분석, 설계기술 Related to the test-first programming concepts of XP 테스트중심의빠른개발방법인 Extreme Programming 과관련 Relies on the repetition of a short development cycle 테스트 - 개발 - 테스트의반복
Test Driven Development(cont.) 일반적인개발과정 디자인 개발 테스트 TDD 개발과정 테스트코드작성 개발 리팩토링
Extreme Programming(XP) Extreme Programming is a discipline of software development based on values of simplicity, communication, feedback, and courage. 불필요한작업은최소한으로줄여, 단기간에가능한좋은제품을고객에게제공하는개발방법론 빠른개발과테스트중심의프로젝트진행 리팩토링과정을통해적절한기능의추가와보완가능
Unit Test What is Unit A unit is the smallest testable part of an application. In procedural programming a unit could be an entire module but is more comm only an individual function or procedure. In object-oriented progra mming a unit is often an entire interface, such as a class, but coul d be an individual method. Application 의가장작은단위인 Unit 을테스트 ( 모듈, 객체등 ) TDD concept 에따라, 개발중반복적으로테스트코드작성 Unit Test Framework : xunit Black Box Test Focus on testing functional requirements
Structural Test Structure based test tests internal structures or workings of an application, as opposed to its functionality Coverage 작성의대표적인예 Coverage = ( 수행성공대상 / 총대상 ) * 100 White Box Test Focus on using internal knowledge of the software
xunit XP style unit testing framework. xunit uses a protocol between a front-e nd to display test results and a test driver linked into applications - remo ving the link time dependencies between the application and the graphic s, formatting libraries. Unit Test 에사용하기위한 Framework xunit 종류 Name JUnit NUnit CUnit CppUnit PHPUnit Language Java.NET C C++ PHP
JUnit What is JUnit Unit testing framework for the Java programming language. JUnit has been important in the development of TDD, and is one of a family of unit testing frameworks collectively known as xunit. Java 에서쓰는 xunit Automation of code execution and results after 테스트코드는개발자가작성 XML 과 HTML 로출력되는결과를다른포맷으로변환및저장가능 Eclipse 에내장 (www.junit.org 에서 download 가능 )
JUnit 3 & JUnit 4 JUnit 3 JUnit 4 Method 는 Test 로시작 @Test 로 Method 지정가능 TestCase 를상속받음 독립클래스로작성 setup(), teardown() 로 Fixture 일일이지정 @Before, @After 로직관적인표현
JUnit 4 Annotation @Before: 테스트전에실행할메소드지정 @After: 테스트후에실행할메소드지정 @BeforeClass: 테스트전에한번만실행할메소드지정 @AfterClass: 테스트후에한번만실행할메소드지정 @Test(timeout=100): 제한시간설정 @Ignore: 테스트제외 직관적인테스트코드작성가능 @Test public void verifygoodzipcode() throws Exception{ Matcher mtcher = this.pattern.matcher(phrase); boolean isvalid = mtcher.matches(); assertequals("pattern did not validate zip code", isvalid, match); }
JUnit 4(cont.) JUnit Methods assertequals - 같은지비교 assertnull - null 값을리턴하는지비교 assertnotnull - 인자로넘겨받은객체가 null 인지판정하고반대인경우실패로처리 assertsame - expected 와 actual 이같은객체를참조하는지판정하고그렇지않다면실패로처리 assertnotsame - expected 와 actual 이서로다른객체를참조하는지판정하고, 만약같은객체를참조한다면실패로처리 asserttrue - boolean 조건이참인지판정 asserttrue - boolean 조건이거짓인지판정 fail - 테스트를바로실패처리
Eclipse Plug-in 1.1 Ant 1.2 Subclipse 1.3 TPTP
Ant 빌드자동화툴 Eclipse 에내장 XML 형태의 Ant 문서작성 (*.ant) 컴파일, 폴더분류, FTP 업로드, 파일압축등의작업일괄처리가능 FTP 사용 Apache 에서 ftp 라이브러리 download 해당라이브러리를 ant Class path 에등록 Xml 파일에 ftp 정보작성
Subclipse SVN(Subversion) Software versioning and revision control system 버전관리시스템 Eclipse IDE 에서 SVN 을사용하기위한 Eclipse Plug-in
TPTP Test & Performance Tools Platform Eclipse 에서진행중인프로젝트및성능관련툴을위한플랫폼 모니터링, 테스팅자동화, 프로파일등의기능 Garbage Collector 로제거되지않는객체를수정가능 높은메모리점유율및지나친수행시간을가지는소스를찾아수정가능
JUnit Practice
JUnit Set-up
JUnit Set-up(cont.)
Coding(class 작성 )
JUnit Test Case 작성
JUnit Test Case 작성 (cont.)
JUnit Test Case 작성 (cont.)
JUnit Test Case 작성 (cont.)
JUnit Test Case 작성 (cont.)
Testing
Testing(cont.)
Testing(cont.)
Testing(cont.)
References < 자바개발자도쉽고즐겁게배우는테스팅이야기 > 이상민 http://blog.naver.com/1jongrak?redirect=log&logno=50132272876 http://searchstory.tistory.com/268 http://xprogramming.com/book/whatisxp/ http://blog.naver.com/softgear?redirect=log&logno=100002991166 http://en.wikipedia.org/wiki/ http://www.extremeprogramming.org/ http://www.junit.org/ http://blog.naver.com/nachaos?redirect=log&logno=110030350613 http://www.ibm.com/developerworks/kr/library/tutorial/j-junit4/ http://www.eclipse.org