2017-12-17 16 views
0

私は、アンチユニットテストに追加したantプロジェクトを持っています。これはテストを実行するターゲットです。私は、エコー文はコンソールまたはレポートに印刷されませんant test-buildを実行するとアンチユニットテストのエコーが表示されない

<target name="test-build" depends="init-build"> 
    <au:antunit> 
     <fileset file="test.xml"/> 
     <au:plainlistener/> 
     <au:xmllistener todir="${reports.antunit.dir}"/> 
    </au:antunit> 
</target> 

のtest.xmlこの

<project xmlns:au="antlib:org.apache.ant.antunit"> 
    <include file="build.xml" as="main"/> 

    <target name="tearDown" depends="main.clean"/> 

    <target name="test-project-name"> 
     <echo>project name is ${ant.project.name}</echo> 
     <au:assertTrue> 
      <equals arg1="${ant.project.name}" arg2="gradle-to-ant"/> 
     </au:assertTrue> 
    </target> 
</project> 

のように見えます。

test-build: 
[au:antunit] Build File: /etc/user/john/projects/gradle-to-ant/test.xml 
[au:antunit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.033 sec 
[au:antunit] Target: test-project-name took 0.012 sec 

BUILD SUCCESSFUL 
Total time: 0 seconds 

私はエコーpropsのような他のプロジェクトで使用さ見てきました。どのようにして、反戦テストでエコーを働かせることができますか?

答えて

2

echoタスクの出力がキャプチャされ、アサーションを使用できるようになります(assertLogContains)。小道具では、標的を手動でantunitの外で実行する場合、echoが存在するかのように見えます。

あなたはすなわち

<au:antunit> 
    <fileset file="test.xml"/> 
    <au:plainlistener/> 
    <au:xmllistener todir="${reports.antunit.dir}"/> 
    <au:logforwarder/> 
</au:antunit> 
+0

、あなたはantunitタスクにlogforwarder testlistenerを追加する必要がechoの出力を確認したい場合は、私はまだこれを試すことができませんでしたが、私はそれが動作すると確信しています。私はまた、すべてのアサートマクロを表示するantlib.xmlも発見しました。これは、アンチユニットを学びたい人に役立ちます。また、抗日の開発に関与してくれてありがとう! –

+0

ようこそ。 AntUnitディストリビューションをApache(またはそのミラーの1つ)からダウンロードする場合は、マニュアルも含まれています。なんらかの理由で、これをデフォルトの配布ポイントと考えていますので、マニュアルをオンラインにすることは決してありません。 –

+0

ああ、それはいいだろう。イムを使ってイニシャルをインストールするImこれがプロジェクトです。 github.com/moaxcp/gradle-to-ant –

関連する問題