Skip to content

Commit 8fcd615

Browse files
committed
Initial commit
0 parents  commit 8fcd615

File tree

5 files changed

+112
-0
lines changed

5 files changed

+112
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go-junit-report

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2012 Joel Stemmer
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
go-junit-report
2+
===============
3+
4+
Converts `go test` output to an xml report, suitable for applications that
5+
expect junit xml reports (e.g. [Jenkins](http://jenkins-ci.org)).
6+
7+
Installation
8+
------------
9+
10+
go get github.com/jstemmer/go-junit-report
11+
12+
go install github.com/jstemmer/go-junit-report
13+
14+
Usage
15+
-----
16+
17+
go test -v | go-junit-report > report.xml
18+

go-junit-report.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io"
6+
"os"
7+
)
8+
9+
type Report struct {
10+
}
11+
12+
func main() {
13+
// Read input
14+
report, err := parse(os.Stdin)
15+
if err != nil {
16+
fmt.Printf("Error reading input: %s\n", err)
17+
os.Exit(1)
18+
}
19+
20+
// Write xml
21+
err = report.XML(os.Stdout)
22+
if err != nil {
23+
fmt.Printf("Error writing XML: %s\n", err)
24+
os.Exit(1)
25+
}
26+
}
27+
28+
func parse(reader io.Reader) (Report, error) {
29+
return Report{}, nil
30+
}
31+
32+
func (r Report) XML(io.Writer) error {
33+
return nil
34+
}

go-junit-report_test.go

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
"testing"
6+
)
7+
8+
const testOutputPass = `=== RUN TestOne
9+
--- PASS: TestOne (0.06 seconds)
10+
=== RUN TestTwo
11+
--- PASS: TestTwo (0.10 seconds)
12+
PASS
13+
ok package/name 0.160s`
14+
15+
func TestOutputPass(t *testing.T) {
16+
_, err := parse(strings.NewReader(testOutputPass))
17+
if err != nil {
18+
t.Fatalf("error parsing: %s", err)
19+
}
20+
}
21+
22+
const testOutputFail = `=== RUN TestOne
23+
--- FAIL: TestOne (0.02 seconds)
24+
file_test.go:11: Error message
25+
file_test.go:11: Longer
26+
error
27+
message.
28+
=== RUN TestTwo
29+
--- PASS: TestTwo (0.13 seconds)
30+
FAIL
31+
exit status 1
32+
FAIL package/name 0.151s`
33+
34+
func TestOutputFail(t *testing.T) {
35+
_, err := parse(strings.NewReader(testOutputPass))
36+
if err != nil {
37+
t.Fatalf("error parsing: %s", err)
38+
}
39+
}

0 commit comments

Comments
 (0)