1

次の問題に直面しました。

Groovy、TestNG、ant を使用してパイロット テスト プロジェクトを作成しようとしています。

IDE (Eclipse) からテストを実行すると、すべて問題ありません。

しかし、antを使用してテストを実行しようとすると、簡単ではありません。私たちを手伝ってくれますか?

build.xml は以下にあります。

ターゲットをコンパイル - OK を渡しますが、runTest ターゲットでは問題が発生します:

「スレッド「メイン」の例外 java.lang.NoClassDefFoundError: groovy/lang/GroovyObject」

<project basedir="." default="runTest" name="Ant file for TestNG">
<property name="src" location="src" />
<property name="build" location="build" />
<property name="libs" location="lib" />

<path id="class.path">
    <pathelement location="${libs}/testng.jar" />
    <pathelement location="lib/testng.jar"/>
    <pathelement location="${build}" />
</path>

<taskdef name="testng" classname="org.testng.TestNGAntTask">
  <classpath>
    <pathelement location="lib/groovy-all.jar"/>
    <pathelement location="lib/testng.jar"/>
  </classpath>
</taskdef>

 <target name="runTest" depends="compile">

  <mkdir dir="testng_output"/><!-- Create the output directory. -->

  <testng outputdir="testng_output" classpathref="class.path"> 
    <xmlfileset dir="." includes="testng.xml"/> 
  </testng>

</target>

<target name="compile">  
    <delete dir="build"/>    
    <mkdir dir="build"/>

    <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="lib/groovy-all.jar"/>

    <groovyc srcdir="src" destdir="./build">
        <classpath>
            <pathelement path="lib/groovy-all.jar"/>
            <pathelement path="lib/testng.jar"/>
        </classpath>
        <javac source="1.7" target="1.7" debug="off" />
    </groovyc>   
</target>

</project> 

そして、これはtestng.xmlです

<suite name="My Test Suite" parallel="methods" thread-count="5">
    <test name="My Test">
        <classes>
            <class name="test1" />
        </classes>
    </test>
</suite>
4

0 に答える 0