Does anyone know how to configure Maven Surefire plugin with Gradle for unit tests?


(Jon Austen) #1

Does anyone know how to configure Maven Surefire plugin with Gradle for unit tests?

http://maven.apache.org/plugins/maven-surefire-report-plugin/

Can anyone provide hints or advice? I don’t want to use TestNG and I want to have HTML generated reports from my JUnit results.

Using “pure Maven” , I believe you need to add this entry to your pom.xml file:

<reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.12.4</version>
      </plugin>
    </plugins>
  </reporting>

Then, somehow do an invoke similar to “mvn site” I think???

I am so lost.


(Luke Daley) #2

Gradle isn’t built on Maven. I’m not sure why you’d want to try and use surefire.

Are you just trying to run tests?


(Jon Austen) #3

Ok, but does Gradle have support for “standard JUnit reports” ? Or, in other words, how would you, being a Gradle developer, handle distribution of JUnit reports, after the “test” task has finished?

Right now I get a .xml output file from Gradle in the build/test-results directory ( from the following configuration) :

test {
    testLogging {
        exceptionFormat "full" // default is "short"
        events "started", "passed", "skipped", "failed", "standardOut", "standardError"
    }
}

I was guessing that Gradle had the ability to load a Maven configuration (in the form of a reporting plugin) and execute it but I am wrong?


(Jon Austen) #4

If you want to re-title my question, you are welcome. It probably should have been “How do I configure JUnit reporting for Gradle tests?”.


(Peter Niederwieser) #5

I was guessing that Gradle had the ability to load a Maven configuration (in the form of a reporting plugin) and execute it but I am wrong?

Gradle doesn’t have this ability.

Your code snippet only configures console logging. It has no influence on the XML/HTML report generated. Gradle does generate an HTML report unless you set ‘test.testReport = false’. It doesn’t look like the (ugly) Ant/Maven JUnit report though. (JUnit itself doesn’t know anything about report generation.)