首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ant&Concordion: Classpath问题

Ant&Concordion: Classpath问题
EN

Stack Overflow用户
提问于 2012-05-31 15:00:14
回答 1查看 876关注 0票数 0

我是刚接触Ant/Concordion的,我关于Stack溢出的第一个问题,希望您能温柔一点。

尝试设置Ant任务以自动运行Concordion验收测试,并生成一个汇总/概述/索引html页面,其中列出哪些测试通过、失败等。

我正在使用Concordion Ant任务,但是有一个问题,我认为我的类路径是不正确的。

包结构镜像为test/java/spec & test/resources/spec,作为夹具和规范之间的分隔。

这是我的build.xml。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project name="Bowling" default="run.acceptance.tests">
    <path id="dependencies">
        <fileset dir="lib" includes="concordion-ant-task-*.jar"/>
        <fileset dir="lib" includes="freemarker*.jar"/>
        <fileset dir="lib" includes="junit*.jar"/>
    </path>

    <taskdef name="junit" 
        classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
    <taskdef name="generate-test-overview"    
        classname="bad.robot.concordion.ant.GenerateTestOverviewTask" 
        classpathref="dependencies"/>

    <target name="check.dependencies"
        unless="classpath.as.supplied.by.maven">
        <!--  <fail message="Missing dependencies, run using Maven instead (*blush*) or switch to use classpathref='dependencies'"/>-->
    </target>

    <target name="generate-overview"
        depends="check.dependencies">
        <generate-test-overview 
            template="src\test\resources\spec\bowlingGame\Overview.ftl"      
            output="src\test\resources\spec\bowlingGame\Overview.html">
            <fileset dir="${basedir}\src\test\resources\spec\bowlingGame\">
                <include name="**/*.html"/>
                <exclude name="**/Overview.html" />
                <exclude name="**/BowlingGame.html" />
            </fileset>
        </generate-test-overview>
    </target>

    <echo message="${basedir}" />

    <target name="run.acceptance.tests"
        depends="generate-overview">
        <junit printsummary="on" haltonfailure="yes">
            <classpath>
                <pathelement location="${basedir}"/>
            </classpath>
            <formatter type="plain"/>
            <test name="Overview"/> <!-- corresponding java fixture, must match the overview page generated -->
        </junit>
    </target>  
</project> 

这是蚂蚁的输出。

代码语言:javascript
复制
        Apache Ant version 1.7.1 compiled on June 27 2008
    Using C:\Documents and Settings\gafitzgerald\training\Bowling\ant.log file as build log.
Buildfile: C:\Documents and Settings\gafitzgerald\training\Bowling\build.xml
parsing buildfile C:\Documents and Settings\gafitzgerald\training\Bowling\build.xml with URI = file:/C:/Documents%20and%20Settings/gafitzgerald/training/Bowling/build.xml
Project base dir set to: C:\Documents and Settings\gafitzgerald\training\Bowling
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
     [echo] C:\Documents and Settings\gafitzgerald\training\Bowling
Build sequence for target(s) `run.acceptance.tests' is [check.dependencies, generate-overview, run.acceptance.tests]
Complete build sequence is [check.dependencies, generate-overview, run.acceptance.tests, ]
check.dependencies:
generate-overview:
[generate-test-overview] looking for files in C:\Documents and Settings\gafitzgerald\training\Bowling\src\test\resources\spec\bowlingGame...
[generate-test-overview]    scoring\Scoring.html
[generate-test-overview]    scoring\Spare.html
run.acceptance.tests:

裁剪

代码语言:javascript
复制
[junit] Implicitly adding C:\Documents and Settings\gafitzgerald\training\lib\junit-4.8.2.jar;C:\java\eclipse-helios\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-launcher.jar;C:\java\eclipse-helios\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant.jar;C:\java\eclipse-helios\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-junit.jar to CLASSPATH
    [junit] Using CLASSPATH C:\Documents and Settings\gafitzgerald\training\Bowling;C:\Documents and Settings\gafitzgerald\training\lib\junit-4.8.2.jar;C:\java\eclipse-helios\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-launcher.jar;C:\java\eclipse-helios\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant.jar;C:\java\eclipse-helios\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-junit.jar
    [junit] Running Overview
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

BUILD FAILED
C:\Documents and Settings\gafitzgerald\training\Bowling\build.xml:31: Test Overview failed
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.actOnTestResult(JUnitTask.java:1840)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:837)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1785)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:785)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
EN

回答 1

Stack Overflow用户

发布于 2013-03-01 14:22:25

我重新设置了Ant文件的格式,这样就更容易阅读了。

我注意到了一些事情:

  • 您不必通过一个JUnit定义<taskdef>任务。<junit>任务是Ant的一部分。我想这就是为什么你要:[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
  • 在运行JUnit测试之前,您需要编译它们。这是<generate-test-overview>的任务吗?通常,在编译JUnit测试时,应该包括在类路径:中。
    • 编译时使用的所有罐子。
    • JUnit测试将要运行的类。
    • junit jar (ant t.jar)的位置已经在类路径中了。

  • 运行叉子JUnit测试。我不知道为什么fork设置为false,但是JUnit测试应该是分叉的。
  • name子实体的<test>参数应该是要执行的类的名称。我不认为Overview是它。
  • 不要在失败时停止JUnit测试。一个测试可能失败,但其他测试可能已经成功。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10836133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档