파이어맨 이야기

Junit & Ant를 이용한 테스트 결과 리포트 생성하기



1. build.xml 사용하여 리포트 생성 설정 추가 (아래와같이 target설정)


  <target name="junit4" depends="compile">

    <junit printsummary="on" fork="false" haltonfailure="false">


      <classpath refid="classpath.project"/>

      <formatter type="xml"/>


      <batchtest todir="${dir.build}">

        <fileset dir="${dir.src}">

          <include name="**/Test*.java"/>

          <exclude name="**/AllTests.java"/>

        </fileset>

      </batchtest>


    </junit>


    <junitreport todir="${dir.build}">

      <fileset dir="${dir.build}">

        <include name="TEST-*.xml"/>

      </fileset>

      <report format="frames" todir="${dir.build}"/>

    </junitreport>


    <pathconvert dirsep="/" property="reportUrl">

      <path>

        <pathelement location="${dir.build}/index.html"/>

      </path>

    </pathconvert>


    <exec executable="cmd" os="Windows XP">

      <arg value="/C"/>

      <arg value="${reportUrl}"/>

    </exec>

  </target>


- include 의 파일이름이 Test*.java로 되어있기 때문에 Junit테스트 클래스 이름을 맞게 설정 



2. batch스크립트 생성


ant clean

ant junit4


- ant clean후 junit4  타겟을 통해 빌드 


3. 자동화 테스트 결과 확인 

프로젝트 아래 build폴더의 리포트 파일 및 결과 확인 



JUnit 자동 테스트 결과 확인 


공유하기

facebook twitter kakaoTalk kakaostory naver band