プロジェクトに直接関連するコード用の「src」ディレクトリと、「src」ディレクトリ内のコードに対して実行される JUnit テストである「test」ディレクトリを持つ Java プロジェクトがあります。ディレクトリ構造は次のようになります。
ROOT/src/com/mycompany/decoders/qDecoder/.....
ROOT/test/com/mycompany/decoders/qDecoder/.....
両方のディレクトリのパッケージ構造はまったく同じです。
以下は、ターゲットと関連する JUnit 情報です。
<property name="src_classes_dir" value="./bin"/>
<property name="test_classes_dir" value="./binTest"/>
<path id="junit.classpath">
<pathelement location="${src_classes_dir}"/>
<pathelement location="${test_classes_dir}"/>
<pathelement location="${CommonJarPath}/JUnit/junit.jar"/>
<pathelement location="${CommonJarPath}/JavaMail/mailapi.jar"/>
<pathelement location="${CommonJarPath}/JavaMail/smtp.jar"/>
<pathelement location="${CommonJarPath}/CommonsLang3/commons-lang3.jar"/>
<pathelement location="${CommonJarPath}/JDBC/inetsoftware/merlia/8.0.2/Merlia.jar"/>
<pathelement location="${CommonJarPath}/JodaTime/joda-time.jar"/>
</path>
<property name="test_dir" value="./test"/>
<target name="junit" description="Run JUnit tests" depends="compile_source, compile_test">
<junit fork="yes" haltonfailure="yes" haltonerror="yes" showoutput="yes">
<formatter type="plain" usefile="no"/>
<classpath refid="junit.classpath"/>
<batchtest>
<fileset dir="${test_dir}" />
</batchtest>
</junit>
</target>
だから、私のテストファイル(*.java)
は${test_dir}
. テスト クラスは に${test_classes_dir}
あり、テストされたクラスは にあり${src_classes_dir}
ます。どちらもjunit.classpath
リファレンスに記載されています。
「junit」ターゲットまでのすべてのターゲット、「clean」、「prep」、「src_compile」、および「test_compile」が完了し、ClassNotFoundException
最初の testを取得しAMCiBitsTest
ます。したがって、テストについては知っていますが、何らかの理由でそのクラスを見つけることができません。
例外トレースは次のとおりです。
junit:
[junit] Testsuite: com.amci.util.AMCiBitsTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit]
[junit] Caused an ERROR
[junit] com.amci.util.AMCiBitsTest
[junit] java.lang.ClassNotFoundException: com.amci.util.AMCiBitsTest
[junit] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[junit] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[junit] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:190)
[junit]
私は困惑しています。私は何を間違っていますか?AMCiBitsTest
これでテストと他のすべてのテストを実行できないのはなぜですか?