====== Test Automation ====== ===== 개요 ===== [[http://en.wikipedia.org/wiki/Test_automation|Test Automation]]은 개발자가 작성한 다수의 단위테스트 클래스(TestCase) 및 TestSuite을 자동으로 수행하고 그 결과 리포트를 생성하는 기능을 제공하는 것을 말한다. Test Automation의 개념과 방법에 대해 알아본다. ===== 설명 ===== **Test Automation**은 **지속적인 통합**([[http://www.martinfowler.com/articles/continuousIntegration.html|Continuous Integration - CI]])를 실천하기 위한 방안 중 하나인 "[[http://www.martinfowler.com/articles/continuousIntegration.html#MakeYourBuildSelf-testing|Make Your Build Self-Testing]]" 개념에서 나온 것으로 개발자 코드에 대해 작성된 단위테스트 클래스들을 자동으로 테스트를 수행하도록 하고, 매일 지속적으로 테스트를 수행하고 그 결과를 확인함으로써 지속적인 통합의 이점을 극대화시키고자 하는 목적을 갖고 있다.\\ [[http://en.wikipedia.org/wiki/Test_automation#Code-driven_testing|Code-driven testing]]에서도 설명하고 있듯이, 개발자가 대상 코드에 대한 여러 개의 단위테스트 클래스를 작성하고 나면, 이를 몇 개 그룹으로 묶거나, 빌드도구를 활용하여 TestCase를 한꺼번에 수행하여 그 결과 리포트를 생성할 수 있다.\\ 그리고, CI서버와 연계하여 주기적으로 빌드를 수행하는 프로세스 중 하나로 포함시킴으로써 **지속적인 테스트**의 기초가 될 수 있다. \\ \\ 좀 더 관심이 있으신 분은 IBM 사이트에 연재되었던 Article "[[http://www.ibm.com/developerworks/kr/library/j-ap03137/|사람을 위한 자동화:연속 테스팅]]"을 참고하기 바란다. ==== Test Automation 오픈소스 ==== Test Automation 수행을 위한 오픈소스로는 Ant와 Maven이 있으며, TestCase 작성을 위한 프레임워크인 JUnit에서 테스트 자동 수행과 리포팅을 위한 기능을 제공한다. ^ 기능 ^ Maven Plug-in ^ Ant Task | | 빌드도구 | [[http://maven.apache.org/|Maven]] 2.0 | [[http://ant.apache.org/|Ant]] 1.6.5 이상 | | 테스트 자동 수행 | [[http://maven.apache.org/plugins/maven-surefire-plugin/|Maven Surefire Plugin]]| [[http://ant.apache.org/manual/OptionalTasks/junit.html|Ant JUnit Task]] | | 테스트 리포트 생성 | [[http://maven.apache.org/plugins/maven-surefire-report-plugin/|Maven Surefire Report Plugin]] | [[http://ant.apache.org/manual/OptionalTasks/junitreport.html|Ant JUnit Report Task]] | 본 개발환경에서는 좀더 많이 사용되는 Ant를 선정했었으나, [[egovframework:dev2:dep:maven|배포도구]]에서 Maven을 선정하였으므로 Ant와 Maven을 이용한 모든 사용법을 함께 설명한다. 그러나, 기본적으로 사용법만 다를 뿐이다. ==== Test Automation 프로세스 ==== * [[Write TestSuite]] : 작성된 다수의 TestCase 클래스들을 수행을 위해 몇 개 그룹 혹은 하나로 묶는다. * [[Run TestSuite]] : TestCase 그룹들의 테스트를 한꺼번에 수행한다. * [[Test Reporting]] : 테스트 수행 결과를 Text, XML, HTML, Excel 형태의 리포트로 생성한다. ===== 환경설정 ===== * Ant, Maven Eclipse Plugin 설치 * JUnit Eclipse Plugin 설치((Eclipse 3.4 JEE 버전에는 기본적으로 JUnit 3.8 버전과 4.3 버전의 Plugin이 설치되어 있다.)) * TestSuite 작성을 위한 라이브러리 추가 (pom.xml) : [[Unit Test 작성을 위한 pom.xml dependency 설정]] 참고 * 엑셀 리포팅을 사용할 경우 [[엑셀 리포팅 사용을 위한 setting.xml 설정|setting.xml에 설정]] 추가 ===== 사용법 ===== Test Automation을 수행하기 위해서는 다음과 같이 진행한다. * [[write_testsuite#사용법|Write TestSuite]] : TestSuite 클래스를 작성하거나, 빌드도구에서 테스트 수행을 하기 위한 TestCase들을 명시한다. * [[Run_TestSuite#사용법|Run TestSuite]] : 빌드도구의 이클립스 플러그인을 이용하여 테스트를 수행한다. * [[Test_Reporting#사용법|Test Reporting]] : 테스트 수행 결과 생성된 Text, XML, HTML, Excel 형태의 리포트를 확인한다. ===== 샘플 ===== ==== Test Automation - Maven ==== [[Test Automation을 위한 pom.xml 설정]]과 같이 설정할 수 있다. ==== Test Automation - Ant ==== [[Test Automation을 위한 build.xml 설정]]과 같이 설정할 수 있다. ===== 참고자료 ===== * JUnit Home : [[http://junit.org/]] * Maven Surefire Plugin Home : [[http://maven.apache.org/plugins/maven-surefire-plugin/]] * Maven Surefire Report Plugin Home : [[http://maven.apache.org/plugins/maven-surefire-report-plugin/]] * Maven Emma Plugin Home : [[http://emma.sourceforge.net/maven-emma-plugin/]] * Ant JUnit Task : [[http://ant.apache.org/manual/OptionalTasks/junit.html]] * Ant JUnit Report Task : [[http://ant.apache.org/manual/OptionalTasks/junitreport.html]] * EMMA Home : [[http://emma.sourceforge.net]] * EclEmma Home : [[http://www.eclemma.org]] * m2eclipse Home : [[http://m2eclipse.sonatype.org/index.html]] * [[http://www.ibm.com/developerworks/kr/series/j-ap.html|'행위의 중복'을 없애는, 사람을 위한 자동화 시리즈]]