Test Automation을 위한 build.xml

다음은 Test Automation을 위한 build.xml 샘플이다. Ant를 사용할 경우 다음과 같이 쓰면 된다.

<?xml version="1.0" encoding="UTF-8"?>
 
<project name="egovframework-dev-tst-ant" basedir="." . . .>
 
    <property name="src.dir" value="src/main/java" />
    <property name="resource.dir" value="src/main/resources" />
    <property name="build.dir" value="build/classes" />
 
    <property name="testsrc.dir" value="src/test/java" />
    <property name="testresource.dir" value="src/test/resources" />
    <property name="testbuild.dir" value="build/testclasses" />
 
    <property name="testreports.dir" value="build/junit-reports" />
 
    <property name="lib.dir" value="lib" />
    <property name="buildlib.dir" value="build/lib" />
 
    <path id="master-classpath">
        <path location="${lib.dir}/ant-1.6.5.jar" />
         . . . 중략 . . .
    </path>
 
    <path id="test-classpath">
        <path location="${lib.dir}/ant-testutil-1.7.1.jar" />
         . . . 중략 . . .
    </path>
 
    <target name="clean">
        <delete failonerror="false" includeEmptyDirs="true">
            <fileset dir="${build.dir}" />
            <fileset dir="${testbuild.dir}" />
            <fileset dir="${testreports.dir}" />
        </delete>
    </target>
 
    <target name="build">
        <mkdir dir="${build.dir}" />
 
        <javac destdir="${build.dir}"
               source="1.5"
               target="1.5"
               debug="true"
               encoding="UTF-8"
               deprecation="false"
               optimize="false"
               failonerror="true">
            <src path="${src.dir}" />
            <classpath refid="master-classpath" />
        </javac>
 
        <jar jarfile="build/${ant.project.name}.jar" compress="true">
            <fileset dir="${build.dir}">
                <include name="**/*" />
            </fileset>
        </jar>
 
        <copy todir="${build.dir}" preservelastmodified="true">
            <fileset dir="${resource.dir}" includes="**/*" />
        </copy>
    </target>
 
    <target name="tests" depends="build" description="Run tests">
 
        <delete dir="${testbuild.dir}" />
        <mkdir dir="${testbuild.dir}" />
        <delete dir="${testreports.dir}" />
        <mkdir dir="${testreports.dir}" />
 
        <javac srcdir="${testsrc.dir}"
               destdir="${testbuild.dir}"
               debug="true"
               encoding="UTF-8"
               deprecation="true">
            <classpath path="${build.dir}" />
            <classpath refid="master-classpath" />
            <classpath refid="test-classpath" />
        </javac>
 
        <copy todir="${testbuild.dir}" preservelastmodified="true">
            <fileset dir="${build.dir}" includes="**/*" />
            <fileset dir="${testresource.dir}" includes="**/*" />
        </copy>
 
        <junit forkmode="perBatch"
               printsummary="true"
               haltonfailure="yes"
               haltonerror="yes">
            <classpath refid="master-classpath" />
            <classpath refid="test-classpath" />
            <classpath path="${testbuild.dir}" />
            <sysproperty key="ant.home" value="${ant.home}" />
 
            <formatter type="xml" />
 
            <batchtest fork="yes" todir="${testreports.dir}">
                <fileset dir="${testbuild.dir}">
                    <include name="**/*Test.class" />
                    <exclude name="**/Abstract*Test.class" />
                </fileset>
            </batchtest>
        </junit>
 
    </target>
 
    <!-- Junit Test Result Report  -->
    <target name="junitreport" depends="tests">
        <junitreport todir="${testhtml.dir}">
            <fileset dir="${testreports.dir}">
                <include name="TEST-*.xml" />
            </fileset>
            <report format="frames" todir="${testhtml.dir}" />
        </junitreport>
    </target>
 
    <path id="egov.lib">
        <path refid="master-classpath" />
        <path location="${antlib.dir}/egovtest/egovframework-dev-tst-ant.jar" />
    </path>
 
    <taskdef resource="egovtest.properties"
             classpathref="egov.lib"
             description="egovtest junit tasks:" />
 
    <!-- JUnit Excel Report -->
    <target name="egovtest" depends="tests">
        <egov-junitreport todir="${testxls.dir}">
            <fileset dir="${testreports.dir}" includes="**/TEST-*.xml" />
        </egov-junitreport>
    </target>
 
    <target name="egovtest-full" depends="tests">
        <egov-junitreport todir="${testxls.dir}"
                          outputname="egovtest-junit-full.xls"
                          templatepath="${basedir}/build/template-kr.xls"
                          summary="0,B,6"
                          packages="0,B,11"
                          lists="1,A,5">
            <fileset dir="${testreports.dir}"
                     includes="**/TEST-*.xml" />
        </egov-junitreport>
    </target>
 
</project>
 
egovframework/dev/tst/test_automation을_위한_build.xml_설정.txt · 마지막 수정: 2023/12/21 05:21 (외부 편집기)
 
이 위키의 내용은 다음의 라이센스에 따릅니다 :CC Attribution-Noncommercial-Share Alike 3.0 Unported
전자정부 표준프레임워크 라이센스(바로가기)

전자정부 표준프레임워크 활용의 안정성 보장을 위해 위험성을 지속적으로 모니터링하고 있으나, 오픈소스의 특성상 문제가 발생할 수 있습니다.
전자정부 표준프레임워크는 Apache 2.0 라이선스를 따르고 있는 오픈소스 프로그램입니다. Apache 2.0 라이선스에 따라 표준프레임워크를 활용하여 발생된 업무중단, 컴퓨터 고장 또는 오동작으로 인한 손해 등에 대해서 책임이 없습니다.
Recent changes RSS feed CC Attribution-Noncommercial-Share Alike 3.0 Unported Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki