Travis CIで使用するbuild.xmlファイルを作成しようとしています。別の/ testディレクトリでJUnitテストを実行するようにbuild.xmlを設定してください。
これは私がこれまでに作ってみたコードです:私は、以下に示すファイル構造、上記のように、クラスファイルと同じディレクトリに私のJUnitテストファイルを配置した場合
<?xml version="1.0" encoding="UTF-8"?>
<project name="Practice" basedir="." default="init">
<property name="src.dir" location="src" />
<property name="bin.dir" location="bin" />
<property name="lib.dir" location="lib" />
<path id="classpath">
<pathelement location="${bin.dir}" />
<pathelement location="${lib.dir}/hamcrest-core-1.3.jar" />
<pathelement location="${lib.dir}/junit-4.11.jar" />
</path>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="init" depends="clean">
<mkdir dir="${bin.dir}" />
<copy includeemptydirs="false" todir="${bin.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.launch" />
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="compile" depends="init" description="compile">
<javac srcdir="${src.dir}" destdir="${bin.dir}" classpathref="classpath" />
</target>
<target name="test" depends="compile">
<mkdir dir="${report.dir}" />
<junit printsummary="yes">
<classpath>
<path refid="classpath" />
</classpath>
<formatter type="xml" />
<test name="folder1.MyClass1Test" todir="${report.dir}" haltonfailure="yes" />
</junit>
</target>
</project>
build.xmlの作品、およびJUnitテストが正常に実行されます。
- src
- folder1
- MyClass1.java
- MyClass1Test.java
私は、しかし、別の/ testディレクトリに私のテストファイルを持っており、構造は以下のようになります。
- src
- folder1
- MyClass1.java
- test
- folder1
- MyClass1Test.java
/testフォルダからテストを実行するために変更する必要があるのはわかりません。私はsrc
の代わりにtest
を指すように別の場所のsrc.dir
の場所を変更しようとしましたが、違うパッケージが存在しないというエラーが表示されます。
提案がありますか?
現代のビルドツールの代わりにAntを使用する理由はありますか? – chrylis
@chrylis私はちょうどCIの世界を模索し始めました。これは私が出会った最初の方法です。私はチェックアウトできる代替ツールについて聞いてうれしいですが、この方法を働かせればいいです。 –
@chrylis「モダンビルドツール」と言えば、GradleやMavenを指していますか? –