0

I have created a build file, and configured it according to my project (Selenium and Junit). Now the issue is when i run build file, it only runs the first class and saves the same in HTML report. Can any one tell me what m doing wrong and what should be edited / or replaced??

<?xml version="1.0" encoding="UTF-8"?>
<project name="ant" default="exec" basedir=".">

    <property name="src" value="./src" />
    <property name="lib" value="./lib" />
    <property name="bin" value="./bin" />
    <property name="report" value="./report" />
    <path id="ant.classpath">
        <pathelement location="${bin}" />
        <fileset dir="${lib}">
            <include name="**/*.jar" />
            <include name="C:/Users/bhmehta/workspace/ant/lib/libs/*.jar" />
        </fileset>
    </path>

    <target name="init">
        <delete dir="${bin}" />
        <mkdir dir="${bin}" />
    </target>

      <target name="compile" depends="init" description="compile the source " >
         <!-- Compile the java code from ${src} into ${build} -->
            <javac debug="true" 
                srcdir="${src}" 
                destdir="${bin}"    
                includeantruntime="false"
                classpathref="ant.classpath"/>
                <!-- Copy files from ${src} into ${build} -->
            <copy todir="${bin}"> 
                <fileset dir="${src}">
                    <exclude name="**/*.java"/>
            </fileset>
            </copy>
      </target>

    <target name="exec" depends="compile">
        <delete dir="${report}" />
        <mkdir dir="${report}" />
        <mkdir dir="${report}/xml" />
            <junit 
                printsummary="yes" 
                haltonfailure="no"
                >
                <classpath><pathelement location="${ant.classpath}" /> </classpath>     

                <test  name="testing.demo" haltonfailure="no" todir="${report}/xml" outfile="TEST-result">
                        <formatter type="xml" />
                </test>         

                <test  name="testing.demo1" haltonfailure="no" todir="${report}/xml" outfile="TEST-result">
                                        <formatter type="xml" />
                </test>

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

I have also tried some of the solutions given to similar questions, using <batchtest </batchtest> tags. But it shows error like

The <junit> type doesn't support ne sted text data (">").

I really don't know what is this all about. Please some one help

4

1 回答 1

1

You have a typo in your batchtest. Should be: <batchtest> </batchtest>. Try this:

<junit haltonfailure="no" printsummary="yes" fork="yes">
    <classpath>
        <pathelement location="${ant.classpath}" />
    </classpath>
    <formatter type="xml"/>
    <batchtest todir="${report}">
        <fileset dir="src" includes="**/*.class" />
    </batchtest>
</junit>

Once your tests will run, configure the build the way you need.

于 2013-08-06T11:13:47.493 回答