Ant build fails when JaCoCo determines that no tests are worth it

To build continuous integration, we use JcCoCo to minimize the number of tests that need to be run. However, according to some signs, he determines that there are no tests at all. For example, if only the image was changed.

Here is a snippet from build.xml :

 <fileset id="int.tests" dir="${build.inttest.source}/java"> <include name="**/*Test.java"/> </fileset> <taskdef name="testng" classname="org.testng.TestNGAntTask" classpath="${build.jars.test}/testng.jar"/> <jacoco:coverage destfile="./inttest-jacoco.exec"> <testng outputDir="./reports/intTest" failureproperty="testNGFailed" haltonfailure="false" verbose="2" workingDir="${build.dir}" classfilesetref="int.tests"> <classpath> <path refid="build.inttest.classpath"/> </classpath> </testng> </jacoco:coverage> 

When tests fail, the testNGFailed property testNGFailed set to true, and the assembly is not subsequently executed.

The entry in this scenario is as follows:

 13:16:49,116 INFO - [testng] =============================================== 13:16:49,116 INFO - [testng] Ant suite 13:16:49,116 INFO - [testng] Total tests run: 0, Failures: 0, Skips: 0 13:16:49,116 INFO - [testng] =============================================== 13:16:49,116 INFO - 13:16:49,191 WARN - [testng] [TestNG] No tests found. Nothing was run 

How can I complete the assembly of the assembly when there is no test to be launched, but failure if testing fails?

Can I get Jacoco to always run at least one test?

Can I make TestNG set to failproperty only when testing fails?

+7
testng ant jacoco
source share
2 answers

Firstly, there is no clover used in the fragment, it is jacoco. Secondly, entering the console you gave does not indicate that something is not working. A warning appears, but no error. When no trial war is conducted, coverage will not be measured.

0
source share

First of all - JaCoCo does not run your tests! Tests are performed by TestNG or JUnit or any other testing environment. JaCoCo simply collects coverage information from this run.

According to http://testng.org/doc/ant.html :

classfilesetref - link to ResourceCollection containing test classes to run

whereas in your case it points to a directory containing .java files, so it seems logical that TestNG cannot find the tests.

0
source share

All Articles