mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-12 00:28:07 -05:00
Initial commit
This commit is contained in:
commit
8fcd615a51
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
go-junit-report
|
20
LICENSE
Normal file
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2012 Joel Stemmer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
||||
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
|
||||
------------
|
||||
|
||||
go get github.com/jstemmer/go-junit-report
|
||||
|
||||
go install github.com/jstemmer/go-junit-report
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
go test -v | go-junit-report > report.xml
|
||||
|
34
go-junit-report.go
Normal file
34
go-junit-report.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Report struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Read input
|
||||
report, err := parse(os.Stdin)
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading input: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Write xml
|
||||
err = report.XML(os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error writing XML: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func parse(reader io.Reader) (Report, error) {
|
||||
return Report{}, nil
|
||||
}
|
||||
|
||||
func (r Report) XML(io.Writer) error {
|
||||
return nil
|
||||
}
|
39
go-junit-report_test.go
Normal file
39
go-junit-report_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const testOutputPass = `=== RUN TestOne
|
||||
--- PASS: TestOne (0.06 seconds)
|
||||
=== RUN TestTwo
|
||||
--- PASS: TestTwo (0.10 seconds)
|
||||
PASS
|
||||
ok package/name 0.160s`
|
||||
|
||||
func TestOutputPass(t *testing.T) {
|
||||
_, err := parse(strings.NewReader(testOutputPass))
|
||||
if err != nil {
|
||||
t.Fatalf("error parsing: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
const testOutputFail = `=== RUN TestOne
|
||||
--- FAIL: TestOne (0.02 seconds)
|
||||
file_test.go:11: Error message
|
||||
file_test.go:11: Longer
|
||||
error
|
||||
message.
|
||||
=== RUN TestTwo
|
||||
--- PASS: TestTwo (0.13 seconds)
|
||||
FAIL
|
||||
exit status 1
|
||||
FAIL package/name 0.151s`
|
||||
|
||||
func TestOutputFail(t *testing.T) {
|
||||
_, err := parse(strings.NewReader(testOutputPass))
|
||||
if err != nil {
|
||||
t.Fatalf("error parsing: %s", err)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user