JUnit

If your test suite produces JUnit-compatible XML reports, you can enable our JUnit parser by annotating your test command with the junit type.

java:
  java_version: java-7-openjdk
  maven_version: '3.3.3'  # See our Java documentation for versions
tests:
  - type: junit
    command: mvn test
    report_files:
    - "target/surefire-reports/*.xml"

Going into detail on the configuration file:

  • The java section sets Java and Maven versions
  • The tests section will run a single command (mvn test) and look for Junit XML reports using the target/surefire-reports/*.xml glob pattern. If your JUnit reporter writes files into a different path, you can specify your own pattern, or a list of patterns.

Also it is possible to customize test command name using name key:

tests:
  - name: JUnit test example
    command: mvn verify
    report_files:
    - "target/surefire-reports/*.xml"

You can see a sample application that’s configured to run mvn test and collect JUnit results here:

https://github.com/solanolabs/spring-mvc-showcase/

Compatibility

Solano’s JUnit parser works with most JUnit-compatible test reporting tools. We test against:

  • Ant
  • Maven (Surefire)
  • Gradle
  • SBT
  • Play
  • Nosetests
  • Mocha
  • PHPUnit

While most JUnit reporters use the same XML schema, not all of them organize the results in the same manner. Solano CI’s preferred schema pattern is to use the classname attribute to identify each individual test. This may require customizing a JUnit reporter to have each test result be displayed individually on a Solano CI build page: