Skip to content

Test report into Jenkins readable format

Igor Maznitsa edited this page Jan 4, 2017 · 3 revisions

There is already developed third part utility go2xunit to make conversion of golang test console output into xunit format which can be recognized by Jenkins, since 2.1.1 version the mvn-golang plugin can save console output as files and it allows us to use below trick

<execution>
  <id>default-get</id>
  <configuration>
    <packages>
      <package>github.com/tebeka/go2xunit</package>
    </packages>
  </configuration>
</execution>                   
<execution>
    <id>default-test</id>
    <configuration>
      <buildFlags>
        <flag>-v</flag>
      </buildFlags>
      <outLogFile>test-out-verbose.log</outLogFile>
      <ignoreErrorExitCode>true</ignoreErrorExitCode>
    </configuration>
</execution>
<execution>
  <id>makeXUnitReport</id>
  <phase>test</phase>
  <goals>
    <goal>custom</goal>
  </goals>
  <configuration>
    <exec>go2xunit</exec>
    <customCommand>-fail</customCommand>
    <buildFlags>
      <flag>-input</flag>
      <flag>${project.build.directory}${file.separator}reports${file.separator}test-out-verbose.log</flag>
      <flag>-output</flag>
      <flag>${project.build.directory}${file.separator}reports${file.separator}xunit.xml</flag>
    </buildFlags>
  </configuration>
</execution>

after test we will get log files produced by golang and go2xunit will convert them into xunit format you can take a look at example of such approach