Commits

Anonymous committed 22e8ade

add skipped count output

Comments (0)

Files changed (2)

 type Test struct {
 	Name, Time, Message string
 	Failed              bool
-	Skipped              bool
+	Skipped             bool
 }
 
 type Suite struct {
 	return count
 }
 
+func (suite *Suite) NumSkipped() int {
+	count := 0
+	for _, test := range suite.Tests {
+		if test.Skipped {
+			count++
+		}
+	}
+
+	return count
+}
+
 func (suite *Suite) Count() int {
 	return len(suite.Tests)
 }
 
 var xmlTemplate string = `<?xml version="1.0" encoding="utf-8"?>
 {{if .Multi}}<testsuites>{{end}}
-{{range $suite := .Suites}}  <testsuite name="{{.Name}}" tests="{{.Count}}" errors="0" failures="{{.NumFailed}}" skip="0">
+{{range $suite := .Suites}}  <testsuite name="{{.Name}}" tests="{{.Count}}" errors="0" failures="{{.NumFailed}}" skip="{{.NumSkipped}}">
 {{range  $test := $suite.Tests}}    <testcase classname="{{$suite.Name}}" name="{{$test.Name}}" time="{{$test.Time}}">
 {{if $test.Failed }}      <failure type="go.error" message="error">
         <![CDATA[{{$test.Message}}]]>
 		t.Fatalf("wrong number of failed %d, should be 1", suite.NumFailed())
 	}
 
+	if suite.NumSkipped() != 1 {
+		t.Fatalf("wrong number of skipped %d, should be 1", suite.NumSkipped())
+	}
+
 	test := tests[0]
 	if test.Name != "TestAdd" {
 		t.Fatalf("bad test name %s, expected TestAdd", test.Name)