forked from joshdk/go-junit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save properties of a test case (joshdk#21)
Some reporters use them to store additional information like file location
- Loading branch information
Showing
3 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright Josh Komoroske. All rights reserved. | ||
// Use of this source code is governed by the MIT license, | ||
// a copy of which can be found in the LICENSE.txt file. | ||
|
||
package junit | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestInjest(t *testing.T) { | ||
tests := []struct { | ||
title string | ||
input []byte | ||
expected []Suite | ||
}{ | ||
{ | ||
title: "xml input", | ||
input: []byte(`<testsuite errors="0" failures="1" file="Foo.java"><testcase name="unit tests" file="Foo.java"/></testsuite>`), | ||
expected: []Suite{ | ||
{ | ||
Tests: []Test{ | ||
{ | ||
Name: "unit tests", | ||
Status: "passed", | ||
Properties: map[string]string{ | ||
"file": "Foo.java", | ||
"name": "unit tests", | ||
}, | ||
}, | ||
}, | ||
Totals: Totals{ | ||
Tests: 1, | ||
Passed: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for index, test := range tests { | ||
name := fmt.Sprintf("#%d - %s", index+1, test.title) | ||
|
||
t.Run(name, func(t *testing.T) { | ||
actual, err := Ingest(test.input) | ||
require.Nil(t, err) | ||
require.NotEmpty(t, actual) | ||
require.Equal(t, test.expected, actual) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters