@@ -72,6 +72,7 @@ func TestPrintTests(t *testing.T) {
7272 testcases := []struct {
7373 name string
7474 testResults []TestResult
75+ maxPassRatio float64
7576 expectedRuns int
7677 expectedPasses int
7778 expectedFails int
@@ -88,11 +89,14 @@ func TestPrintTests(t *testing.T) {
8889 TestName : "Test1" ,
8990 TestPackage : "package1" ,
9091 PassRatio : 0.75 ,
92+ Successes : 3 ,
93+ Failures : 1 ,
9194 Skipped : false ,
9295 Runs : 4 ,
9396 Durations : []time.Duration {time .Millisecond * 1200 , time .Millisecond * 900 , time .Millisecond * 1100 , time .Second },
9497 },
9598 },
99+ maxPassRatio : 1.0 ,
96100 expectedRuns : 4 ,
97101 expectedPasses : 3 ,
98102 expectedFails : 1 ,
@@ -102,6 +106,38 @@ func TestPrintTests(t *testing.T) {
102106 expectedFlakyTests : 1 ,
103107 expectedStringsContain : []string {"Test1" , "package1" , "75.00%" , "false" , "1.05s" , "4" , "0" },
104108 },
109+ {
110+ name : "multiple passing tests" ,
111+ testResults : []TestResult {
112+ {
113+ TestName : "Test1" ,
114+ TestPackage : "package1" ,
115+ PassRatio : 1.0 ,
116+ Skipped : false ,
117+ Successes : 4 ,
118+ Runs : 4 ,
119+ Durations : []time.Duration {time .Millisecond * 1200 , time .Millisecond * 900 , time .Millisecond * 1100 , time .Second },
120+ },
121+ {
122+ TestName : "Test2" ,
123+ TestPackage : "package1" ,
124+ PassRatio : 1.0 ,
125+ Skipped : false ,
126+ Successes : 4 ,
127+ Runs : 4 ,
128+ Durations : []time.Duration {time .Millisecond * 1200 , time .Millisecond * 900 , time .Millisecond * 1100 , time .Second },
129+ },
130+ },
131+ maxPassRatio : 1.0 ,
132+ expectedRuns : 8 ,
133+ expectedPasses : 8 ,
134+ expectedFails : 0 ,
135+ expectedSkippedTests : 0 ,
136+ expectedPanickedTests : 0 ,
137+ expectedRacedTests : 0 ,
138+ expectedFlakyTests : 0 ,
139+ expectedStringsContain : []string {},
140+ },
105141 }
106142
107143 for _ , testCase := range testcases {
@@ -110,7 +146,7 @@ func TestPrintTests(t *testing.T) {
110146 t .Parallel ()
111147 var buf bytes.Buffer
112148
113- runs , passes , fails , skips , panickedTests , racedTests , flakyTests := PrintTests (& buf , tc .testResults , 1.0 )
149+ runs , passes , fails , skips , panickedTests , racedTests , flakyTests := PrintTests (& buf , tc .testResults , tc . maxPassRatio )
114150 assert .Equal (t , tc .expectedRuns , runs , "wrong number of runs" )
115151 assert .Equal (t , tc .expectedPasses , passes , "wrong number of passes" )
116152 assert .Equal (t , tc .expectedFails , fails , "wrong number of failures" )
@@ -121,8 +157,7 @@ func TestPrintTests(t *testing.T) {
121157
122158 // Get the output as a string
123159 output := buf .String ()
124- expectedContains := []string {"Test1" , "package1" , "75.00%" , "false" , "1.05s" , "4" , "0" }
125- for _ , expected := range expectedContains {
160+ for _ , expected := range tc .expectedStringsContain {
126161 assert .Contains (t , output , expected , "output does not contain expected string" )
127162 }
128163 })
0 commit comments