2016-07-18 13 views
0

私のカスタムNetBeansプロジェクトでは、project.xmlファイルのアクションとmy build.xmlのAntターゲットの組み合わせを使用して、NetBeans UIで単一のJUnitテストを実行できます。私のテストをTestNGに移植する際に、NetBeans UIを使用してTestNGテストを1回実行できるようにしたいと考えています。残念ながら、これは予想以上に難しくなっています。ここに私のAntターゲットです:NetBeans 8.1で単一のTestNGテストを実行

<target name="testng-single" depends="compile-test" description="Run individual testng test" > 
<testng failureproperty="test.failed" haltonfailure="yes" outputDir="src/testng/test-output" workingDir="." > 
    <classpath refid="classpath.test" /> 
    <classpath refid="classpath.groovy" /> 
    <classpath location="${build}"/> 
    <classpath location="src/testng"/> 
    <classfileset dir="src/testng" includesfile="${test.class}" /> 
</testng> 
<fail message="Tests failed!" if="test.failed"/> 
</target> 

はここに私のアクションです:

<action name="test.single"> 
    <script>build.xml</script> 
    <target>testng-single</target> 
    <context> 
     <property>test.class</property> 
     <folder>src/testng</folder> 
     <pattern>\.java$</pattern> 
     <format>java-name</format> 
     <arity> 
      <one-file-only/> 
     </arity> 
    </context> 
</action> 

私はテストファイルを右クリックして、テストファイルを選択し、それが実行されるとき、それがクラスを見つけることができないことができます。私はこれらの線に沿ってのエラーを参照してください。

Includesfile D:\javamarket\ftharness\com.javamarket.testng.donothing.DoNothingTest not found. 

Ftharnessは私のプロジェクトとのsrc/TestNGのための最上位ディレクトリであるTestNGのテストが含まれている。この下のディレクトリです。私は成功せずに様々な変更を試みました。誰も助けることができますか?

答えて

0

これが同じ問題を解決しようとしている人を助ける場合は、次のように解決しました。それは素晴らしいことではありませんが、うまくいくようです。

本質的に、TestNGのテスト定義をXMLファイルとして使用しています。私はこれらの線に沿ってAntターゲットを作成しました:

<target name="testng-single" depends="compile-test" description="Run individual testng test" > 
<copy file="${tst.dir}/TestSingle.xml" overwrite="true" tofile="${tst.dir}/TempTestSingle.xml" > 
<filterset> 
<filter token="CLASS" value="${test.class}"/> 
</filterset> 
</copy> 
<testng failureproperty="test.failed" haltonfailure="yes" outputDir="src/testng/test-output" suitename="TestNG Suite" testname="TestNG Name" workingDir="." > 
<classpath refid="classpath.test" /> 
<classpath refid="classpath.groovy" /> 
<classpath location="${build}"/> 
<classpath location="src/testng"/> 
<xmlfileset dir="${tst.dir}" includes="TempTestSingle.xml" /> 
</testng> 
<fail message="Tests failed!" if="test.failed"/> 
</target> 

はproject.xmlファイルに以下を追加しました:

<action name="test.single"> 
<script>build.xml</script> 
<target>testng-single</target> 
<context> 
<property>test.class</property> 
<folder>src/testng</folder> 
<pattern>\.java$</pattern> 
<format>java-name</format> 
<arity> 
<one-file-only/> 
</arity> 
</context> 
</action> 

とこのようになりますTestSingle.xmlファイルを追加:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > 
<suite name="Single Method Suite"> 
<test name="Single Method Test"> 
<classes> 
<class name="@[email protected]"> 
<methods> 
<include name=".*" /> 
</methods> 
</class> 
</classes> 
</test> 
</suite> 

これらの変更により、TestNG Javaクラスの1つを右クリックして実行できるようになりました。

これが誰かを助けることを願っています! Martin

関連する問題