diff --git a/README.md b/README.md index e18f37c..aed61be 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,22 @@ -go-junit-report -=============== +# go-junit-report Converts `go test` output to an xml report, suitable for applications that expect junit xml reports (e.g. [Jenkins](http://jenkins-ci.org)). -Installation ------------- +[![Build Status](https://travis-ci.org/jstemmer/go-junit-report.svg)](https://travis-ci.org/jstemmer/go-junit-report) - go get github.com/jstemmer/go-junit-report -Usage ------ +## Installation + +Go version 1.1 or higher is required. Install or update using the `go get` +command: + + go get -u github.com/jstemmer/go-junit-report + +## Usage + +go-junit-report reads the `go test` verbose output from standard in and writes +junit compatible XML to standard out. go test -v | go-junit-report > report.xml diff --git a/junit-formatter.go b/junit-formatter.go index f9ea0c1..b081660 100644 --- a/junit-formatter.go +++ b/junit-formatter.go @@ -102,8 +102,7 @@ func JUnitReportXML(report *Report, w io.Writer) error { writer := bufio.NewWriter(w) - // remove newline from xml.Header, because xml.MarshalIndent starts with a newline - writer.WriteString(xml.Header[:len(xml.Header)-1]) + writer.WriteString(xml.Header) writer.Write(bytes) writer.WriteByte('\n') writer.Flush() diff --git a/tests/02-report.xml b/tests/02-report.xml index e42d7b8..bfa33d7 100644 --- a/tests/02-report.xml +++ b/tests/02-report.xml @@ -4,10 +4,7 @@ - file_test.go:11: Error message -file_test.go:11: Longer - error - message. + file_test.go:11: Error message file_test.go:11: Longer error message.