构建文件不执行测试

时间:2013-12-11 06:56:49

标签: java eclipse apache selenium-webdriver

这是我在eclipse中的项目结构.Inside config保存浏览器名称,testurl等所有环境属性。 我的问题是我从junit文件执行时执行的测试。从build.xml执行时,测试失败(浏览器无法启动)。 构建文件 -

<property name="RELEASE_ROOT" value=".." />
<property name="SRC" value="${RELEASE_ROOT}/src" /> <!-- Change it to your source folder -->
<property name="LIB" value="${RELEASE_ROOT}/src/lib" /> <!-- Change it to your lib folder --> 
<property name="BIN" value="${RELEASE_ROOT}/bin1" /> <!-- Change it to your binary folder where you need to gerate the compiled binary file -->
<property name="REPORT" value="${RELEASE_ROOT}/report" /> <!-- Change it to your output report folder -->
<path id="test.classpath"> <!-- Creating a classpath for use while compiling -->
    <pathelement location="${BIN}" />
    <fileset dir="${LIB}">
        <include name="**/*.jar" />
    </fileset>
</path>
<target name="init"> <!-- Initialization target which deletes and recreates the binary folder.-->
    <delete dir="${BIN}" />
    <mkdir dir="${BIN}" />
</target>
<target name="compile" depends="init"> <!-- Target for compiling the source folder  -->
    <javac source="1.7" srcdir="${SRC}" fork="true" destdir="${BIN}" >
        <classpath>
            <pathelement path="${BIN}">
            </pathelement>
            <fileset dir="${LIB}">
                <include name="**/*.jar" />
            </fileset>
        </classpath>
    </javac>

</target>
<target name="run-single-test" depends="compile"> <!-- Target for running a single test -->
    <delete dir="${REPORT}" />
    <mkdir dir="${REPORT}" />
        <mkdir dir="${REPORT}/xml" /> <!-- Creating a xml folder under the report folder for saving the report output. -->
    <junit printsummary="yes" haltonfailure="no">
        <classpath>
            <pathelement location="${BIN}" />
            <fileset dir="${LIB}">
                <include name="**/*.jar" />
            </fileset>
        </classpath>

        <test name="com.bsb.portal.TopPage.script.ExecuteTest" haltonfailure="no" todir="${REPORT}/xml" outfile="TEST-result"> <!-- Change the class in name="" to your Java test class. -->
            <formatter type="xml" />
        </test>
    </junit>
    <junitreport todir="${REPORT}"> <!-- This section generated the Junit report in html to "html" folder from the xml file. -->
        <fileset dir="${REPORT}/xml">
            <include name="TEST*.xml" />
        </fileset>
        <report format="frames" todir="${REPORT}/html" />
    </junitreport>

</target>
<target name="run-batch-test" depends="compile"> <!-- Target to run test in batches. -->
    <delete dir="${REPORT}" />
            <mkdir dir="${REPORT}" />
                <mkdir dir="${REPORT}/xml" />
    <junit printsummary="yes" haltonfailure="no">
        <classpath>
            <pathelement location="${BIN}" />
            <pathelement location="${SRC}" />
            <fileset dir="${LIB}">
                <include name="**/*.jar" />
            </fileset>
        </classpath>
        <formatter type="xml" usefile="true" />
        <batchtest fork="yes" todir="${REPORT}/xml">
            <fileset dir="${SRC}">
                <include name="**/Test*.java" />

            </fileset>
        </batchtest>

    </junit>
    <junitreport todir="${REPORT}">
        <fileset dir="${REPORT}/xml">
            <include name="TEST*.xml" />
        </fileset>
        <report format="frames" todir="${REPORT}/html" />
    </junitreport>

</target>

请建议需要。

0 个答案:

没有答案