报告细节JUnit任务不对

时间:2014-09-30 16:06:57

标签: java eclipse ant junit sikuli

我正在使用Eclipse,JUnit,Sikuli,Ant和Ubuntu。

我创建了一个JUnit任务,用于运行套件测试并以html格式生成报告。在控制台中,五个测试用例中的一个显示此错误:

  

[junit] [error] Region.waitVanish:似乎在磁盘上找不到imagefile

出于目的,我改变了图像文件名,因为做错了,测试显示没有失败。

  

[junit]测试运行:5,失败:0,错误:0,已过去时间:780,548秒

问题是生成的报告没有显示正确的结果,因为在登录控制台中,首先,junit向我显示错误,其次,最终结果显示一切正常。现在是否更清楚,或者我展示的那条线不被视为错误? 有人可以帮我这个吗?有任何想法吗?非常感谢。

Build.xml代码:

<target name="init">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../Eclipse/eclipse"/>
    <property name="sourceDir" value="src"/>
    <property name="reportsDir" value="reports"/>
    <property name="buildDir" value="bin"/>

    <property name="target" value="1.5"/>
    <property name="source" value="1.5"/>

    <path id="JUnit 4.libraryclasspath">
        <pathelement location="${ECLIPSE_HOME}/plugins/org.junit_4.11.0.v201303080030/junit.jar"/>
        <pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
        <pathelement location="${ECLIPSE_HOME}/plugins/org.apache.ant.source_1.8.4.v201303080030.jar"/>
    </path>

    <path id="Tests.classpath">
        <pathelement location="${buildDir}"/>
        <pathelement location="../../Sikuli/sikuli-java.jar"/>
        <path refid="JUnit 4.libraryclasspath"/>
    </path>
</target>


<!-- Deletes the existing build and dist directory-->
<target name="clean" depends="init">
    <delete dir="${buildDir}" includes="**/*.class" />
    <delete dir="${reportsDir}" />
    <delete file="ReportsConsole.doc"/>
</target>

<!-- Creates the  build and dist directory-->
<target name="prepare" depends="clean">
    <mkdir dir="${reportsDir}"/>
    <mkdir dir="${reportsDir}/html"/>
    <mkdir dir="${buildDir}"/>
    <touch file="ReportsConsole.doc"/>
</target>    

<target name="compile" depends="clean,prepare">
    <javac srcdir="${sourceDir}" destdir="${buildDir}" includeantruntime="false" debug="true" optimize="true" deprecation="false" failonerror="true" compiler="javac1.7">
        <classpath refid="Tests.classpath"/>
    </javac>

    <javac srcdir="${sourceDir}" destdir="${buildDir}" includeantruntime="false" debug="true" optimize="true" deprecation="false" failonerror="true" compiler="javac1.7">
        <classpath refid="JUnit 4.libraryclasspath" />
    </javac>

</target>

<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
    <copy todir="${ant.library.dir}">
        <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
    </copy>
    <unzip dest="${ant.library.dir}">
        <patternset includes="jdtCompilerAdapter.jar"/>
        <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
    </unzip>
</target>

<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
    <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
    <antcall target="build"/>
</target>

<target name="run" depends="compile"/>

<target name="test" depends="compile">
    <junit printsummary="true" haltonfailure="yes" showoutput="yes" fork="yes">
            <classpath refid="Tests.classpath"/>
            <classpath refid="JUnit 4.libraryclasspath"/>
            <classpath>
                <pathelement location="${buildDir}"/>
            </classpath>

            <formatter type="xml" usefile="true"/>
                 <batchtest fork="yes" todir="${reportsDir}">
                        <fileset dir="${buildDir}">
                            <include name="**/*TestSuite01*"/> 
                        </fileset> 
                 </batchtest>
    </junit>
</target>

<target name="junitreport">
    <junitreport todir="${reportsDir}">
        <fileset dir="${reportsDir}">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="noframes" todir="${reportsDir}/html" styledir="../../apache-ant-1.9.4/etc/"/>
    </junitreport>
</target>

带错误的TestCase方法:

@Test
public void testCTA03() throws IOException, JAXBException, FindFailed, InterruptedException {

    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Date date = new Date();

    String filePath = "/XXXX/XXXX/workspace_Eclipse/Tests/databases/BD_CTA03.xml";

    if (filePath.equalsIgnoreCase(null)|| filePath.isEmpty()){
        throw new IOException("Arquivo BD_CTA03.xml não encontrado");
    }

    ReadDataBase rdb = new ReadDataBase();
    rdb.readdatabaseXML(filePath);
    Screen s = new Screen();
    CarregarImagens ci = new CarregarImagens();

    System.out.println("Iniciando a execução do caso de teste CTA03 - INTEGRADA 'Rodando em máquina local sem integrações' - "
            + dateFormat.format(date) + "\n");

    IniciarApp app = new IniciarApp();
    EscolherPaginaPrimaria epp = new EscolherPaginaPrimaria();
    FecharApp fapp = new FecharApp();   

    int i = 1;
    app.verificarTerminal();
    for (Item item : rdb.getTestsdata().getItem()) {
        System.out.println("\n" + i + " - Iteração de Dados\n");
        String paginaprimaria = item.getPaginaPrimaria();
        if (paginaprimaria.equalsIgnoreCase("ISOLADA")){
            System.out.println("A página primária do XML foi 'ISOLADA'\n");
        } else {
            epp.escolherPaginaPrimaria(paginaprimaria);
            s.waitVanish(ci.carregarImagens("msg_naopossuiduasredes-")); ** Inexistent Image Name for test**
            System.out.println("Mensagem informando que não possui duas redes foi exibida com sucesso!\n");


          }
        System.out.println("\n" + i + " - Iteração de Dados Concluída\n");
        i++;            
    }
    fapp.fecharApp();


    System.out.println("CTA03 - Passed\n");
    System.out.println("-------------------------------------------\n");
}

0 个答案:

没有答案