0

我正在使用 ant 运行我的 testng 测试。我得到一个 noclassdeffounderror。我相信这是因为我没有正确设置我的类路径,但我似乎无法弄清楚。`

<!-- This is the command that will be run when the tests are run from outside the vob and for 
SWIT purposes. The only test that should be run is the SWIT group which is the only test
needed for SWIT in the jar file. -->
<target name="run-swit-tests">
    <tstamp>
        <format property="touch.time" pattern="MM_dd_yyyy_hh_mm_aa" offset="-5" unit="hour" />
    </tstamp>

    <echo>Exluding non-SWIT groups: ${nonswit.groups}</echo>

    <testng outputdir="reports" 
        haltonfailure="false" verbose="2" excludedgroups="${nonswit.groups}">
        <classpath>
               <pathelement path="${TestClasses}"/>
               <pathelement path="${Libs}"/>
        </classpath>
        <jvmarg value="-Dtangosol.coherence.cacheconfig=foo.xml" />
        <jvmarg value="-Dtangosol.coherence.override=bar.xml" />
        <jvmarg value="-Dtangosol.coherence.distributed.localstorage=false" />
        <jvmarg value="-Dtangosol.pof.enabled=true" />
        <jvmarg value="-Dtangosol.coherence.management=all" />
        <jvmarg value="-Dtangosol.coherence.member=${user.name}-${touch.time}" />

        <jvmarg value="-javaagent:lib/org.springframework.instrument-3.0.5.RELEASE.jar" />

        <classfileset dir="." includes="**/Test*.class" excludes="**/Abstract*.class ${excluded.tests}"/>

        <reporter>
            <property name="generateGroupsAttribute" value="true" />
        </reporter>
    </testng>
</target>`

非常感谢任何帮助。这是错误:引起:java.lang.ClassNotFoundException:org.springframework.test.context.testng.AbstractTestNGSpringContextTests

4

1 回答 1

0

似乎我所有的罐子都放在 lib 文件夹中,但路径声明在某种程度上是错误的。这是我为解决问题而添加的。 <path id="testng.classpath"> <fileset dir="${Libs}"> <include name="**/*.jar"/> </fileset> </path>我从 ant 任务中删除了 Libs 路径元素,并将其替换为对 testng.classpath 的引用,并找到了我的所有类。

于 2012-05-26T15:33:54.403 回答