2008-09-09 11 views

답변

14

(다음은 어떤 표준 디렉토리 구조로 전환 할 수있다) :

<property file="build.properties" /> 
<property name="source" location="src/main/java" /> 
<property name="test.source" location="src/test/java" /> 
<property name="target.dir" location="target" /> 
<property name="target" location="${target.dir}/classes" /> 
<property name="test.target" location="${target.dir}/test-classes" /> 
<property name="instr.target" location="${target.dir}/instr-classes" /> 

클래스 경로 : 당신이 설정할 필요가

<path id="compile.classpath"> 
    <fileset dir="lib/main"> 
    <include name="*.jar" /> 
    </fileset> 
</path> 

<path id="test.compile.classpath"> 
    <path refid="compile.classpath" /> 
    <pathelement location="lib/test/junit-4.6.jar" /> 
    <pathelement location="${target}" /> 
</path> 

<path id="junit.classpath"> 
    <path refid="test.compile.classpath" /> 
    <pathelement location="${test.target}" /> 
</path> 

우선 Ant는 Emma 라이브러리를 찾을 수 있습니다.

작업 :

<taskdef resource="emma_ant.properties" classpathref="emma.lib" /> 

그런 악기 코드 :

<target name="coverage.report" depends="coverage.instrumentation"> 
    <emma> 
     <report sourcepath="${source}" depth="method"> 
      <fileset dir="${coverage}" > 
       <include name="*.emma" /> 
      </fileset> 
      <html outfile="${coverage}/coverage.html" /> 
     </report> 
    </emma> 
</target> 
+0

: 여기

은 예입니다 –

0
: 마지막으로 보고서를 생성

<jvmarg value="-Demma.coverage.out.file=${coverage}/coverage.emma" /> 
<jvmarg value="-Demma.coverage.out.merge=true" /> 

:

<target name="coverage.instrumentation"> 
    <mkdir dir="${instr.target}"/> 
    <mkdir dir="${coverage}"/> 
    <emma> 
     <instr instrpath="${target}" destdir="${instr.target}" metadatafile="${coverage}/metadata.emma" mode="copy"> 
      <filter excludes="*Test*"/> 
     </instr> 
    </emma> 
    <!-- Update the that will run the instrumented code --> 
    <path id="test.classpath"> 
     <pathelement location="${instr.target}"/> 
     <path refid="junit.classpath"/> 
     <pathelement location="${emma.dir}/emma.jar"/> 
    </path> 
</target> 

는 다음과 같은 적절한 VM의 인수 대상을 실행

Emma 2.1에서는 다른 방법을 소개합니다. f 런타임 적용 범위 정보 (.ec 파일)를 얻습니다. 계측 된 응용 프로그램이 실행되는 컴퓨터의 지정된 포트에서 원격으로 데이터를 요청할 수 있습니다. 따라서 VM을 중지 할 필요가 없습니다.

<emma> 
    <ctl connect="${emma.rt.host}:${emma.rt.port}" > 
     <command name="coverage.get" args="${emma.ec.file}" /> 
     <command name="coverage.reset" /> 
    </ctl> 
</emma> 

다른 단계 엠마 2.0 유사합니다

은 당신이 당신의 테스트 및 발생 범위 보고서의 실행 사이에 Ant 스크립트에 다음 코드를 삽입해야 런타임 범위 데이터와 파일을 얻으려면. 그들은 완벽 엠마에 previous post

더 많은 정보 2.1 기능이 설명되어 있습니다 만 실행에서 계측 된 코드를 분리해서하지 않는 것이 너무 http://sourceforge.net/project/shownotes.php?group_id=108932&release_id=336859

2

User Guide has a good example of how to set up your build script을뿐만 아니라 모든 그래서 같은 <target>에 포함입니다 당신 돈 일련의 다른 목표를 실행해야하지만 대신 ant emma tests과 같은 작업을 수행 할 수 있습니다 (예 : 일반적으로 단위 테스트를 수행하는 방법이 ant tests 인 경우). 당신이 $ {범위}을 정의처럼 보이지 않는

<target name="emma" description="turns on EMMA instrumentation/reporting" > 
    <property name="emma.enabled" value="true" /> 
    <!-- EMMA instr class output directory: --> 
    <property name="out.instr.dir" value="${basedir}/outinstr" /> 
    <mkdir dir="${out.instr.dir}" /> 
</target> 

<target name="run" depends="init, compile" description="runs the examples" > 
    <emma enabled="${emma.enabled}" > 
     <instr instrpathref="run.classpath" 
      destdir="${out.instr.dir}" 
      metadatafile="${coverage.dir}/metadata.emma" 
      merge="true" 
     /> 
    </emma> 

    <!-- note from matt b: you could just as easily have a <junit> task here! --> 
    <java classname="Main" fork="true" > 
     <classpath> 
     <pathelement location="${out.instr.dir}" /> 
     <path refid="run.classpath" /> 
     <path refid="emma.lib" /> 
     </classpath> 
     <jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" /> 
     <jvmarg value="-Demma.coverage.out.merge=true" /> 
    </java> 

    <emma enabled="${emma.enabled}" > 
     <report sourcepath="${src.dir}" > 
     <fileset dir="${coverage.dir}" > 
      <include name="*.emma" /> 
     </fileset> 

     <txt outfile="${coverage.dir}/coverage.txt" /> 
     <html outfile="${coverage.dir}/coverage.html" /> 
     </report> 
    </emma> 
</target>