I have made an Ant target that runs my JUnit 4 tests. Unfortunately all of them are executed twice!
Does anyone have an idea of what I have done wrong?
Here are my ant target:
<target name="junit" description="Execute unit tests" depends="compile">
<delete dir="rawtestoutput"/>
<delete dir="test-reports"/>
<mkdir dir="rawtestoutput"/>
<junit printsummary="on" failureproperty="junit.failure" fork="true">
<classpath refid="class.path.junit"/>
<formatter type="xml" usefile="true" />
<batchtest todir="rawtestoutput">
<fileset dir="src/test">
<include name="**/*.java"/>
<!-- Add util and testhelper classes here (to avoid "No tests in class" error) and add suite classes to avoid test being run twice -->
<exclude name="**/SessionHelper.java"/>
<exclude name="**/TestHelper.java"/>
<exclude name="**/AllTests.java"/>
<exclude name="**/AllEDITests.java"/>
</fileset>
</batchtest>
</junit>
<junitreport>
<fileset dir="rawtestoutput"/>
<report todir="test-reports"/>
</junitreport>
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
</target>
My first idea was that it because of test suites. But I do not think that anymore. I have excluded the tests suites and furthermore, it not only the tests that are part of suites that are run twice. Its all my tests.
Below is a small sample of the test output of one of my testsclasses:
[20:24:53]: [junit] Running dk.gensam.gaia.business.ydelse.YdelsestypeBOTest
[20:24:53]: [junit] dk.gensam.gaia.business.ydelse.YdelsestypeBOTest (2s)
[20:24:54]: [dk.gensam.gaia.business.ydelse.YdelsestypeBOTest] loadYdelsevariationer
[20:24:55]: [loadYdelsevariationer] [Test Output] EMMA: collecting runtime coverage data ...
[20:24:55]: [dk.gensam.gaia.business.ydelse.YdelsestypeBOTest] loadYdelsestypeIndex_alleExisterendeErAnnullerede
[20:24:56]: [dk.gensam.gaia.business.ydelse.YdelsestypeBOTest] loadYdelsestypeIndex_ingenEksisterendeValgteRelationer
[20:24:56]: [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 3,077 sec
[20:24:56]: dk.gensam.gaia.business.ydelse.YdelsestypeBOTest (3s)
[20:24:56]: [dk.gensam.gaia.business.ydelse.YdelsestypeBOTest] loadYdelsevariationer
[20:24:56]: [dk.gensam.gaia.business.ydelse.YdelsestypeBOTest] loadYdelsestypeIndex_alleExisterendeErAnnullerede
[20:24:56]: [dk.gensam.gaia.business.ydelse.YdelsestypeBOTest] loadYdelsestypeIndex_ingenEksisterendeValgteRelationer
As you can see the tests in YdelsestypeBOTest are run twice...