@@ -50,12 +50,12 @@ func TestGenerateSummaryData(t *testing.T) {
5050 PanickedTests : 0 ,
5151 RacedTests : 0 ,
5252 FlakyTests : 2 ,
53- FlakyTestRatio : "66.66 %" ,
53+ FlakyTestRatio : "66.67 %" ,
5454 TotalRuns : 19 ,
5555 PassedRuns : 15 ,
5656 FailedRuns : 4 ,
5757 SkippedRuns : 0 ,
58- PassRatio : "78.94 %" ,
58+ PassRatio : "78.95 %" ,
5959 MaxPassRatio : 0.9 ,
6060 },
6161 },
@@ -72,7 +72,7 @@ func TestGenerateSummaryData(t *testing.T) {
7272 PanickedTests : 1 ,
7373 RacedTests : 1 ,
7474 FlakyTests : 2 ,
75- FlakyTestRatio : "66.66 %" ,
75+ FlakyTestRatio : "66.67 %" ,
7676 TotalRuns : 18 ,
7777 PassedRuns : 17 ,
7878 FailedRuns : 1 ,
@@ -142,6 +142,66 @@ func TestGenerateSummaryData(t *testing.T) {
142142 MaxPassRatio : 0.85 ,
143143 },
144144 },
145+ {
146+ name : "Tiny flake ratio that rounds up to 0.01%" ,
147+ testResults : func () []TestResult {
148+ // Create 9,999 test results in total:
149+ // - 9,998 stable (PassRatio=1.0) => not flaky
150+ // - 1 flaky (PassRatio=0.5) => definitely flaky
151+ const total = 9999
152+ tests := make ([]TestResult , total )
153+ for i := 0 ; i < total - 1 ; i ++ {
154+ tests [i ] = TestResult {
155+ PassRatio : 1.0 , // 100% success
156+ Runs : 10 ,
157+ Successes : 10 ,
158+ Failures : 0 ,
159+ Skips : 0 ,
160+ Skipped : false ,
161+ Panic : false ,
162+ Race : false ,
163+ }
164+ }
165+ // This final test is partially failing => PassRatio=0.5 => "flaky"
166+ tests [total - 1 ] = TestResult {
167+ PassRatio : 0.5 ,
168+ Runs : 2 ,
169+ Successes : 1 ,
170+ Failures : 1 ,
171+ }
172+ return tests
173+ }(),
174+ maxPassRatio : 1.0 ,
175+ expected : SummaryData {
176+ // 9,999 total test results:
177+ TotalTests : 9999 ,
178+ // None of them panic or race:
179+ PanickedTests : 0 ,
180+ RacedTests : 0 ,
181+ // Exactly one is flaky:
182+ FlakyTests : 1 ,
183+ // Flaky ratio = 1 / 9999 ≈ 0.00010001 => 0.01% after rounding
184+ FlakyTestRatio : "0.01%" ,
185+
186+ // Total runs = 9,998 stable tests * 10 runs each + 1 flaky test with 2 runs
187+ TotalRuns : (9998 * 10 ) + 2 , // = 99,980 + 2 = 99,982
188+
189+ // Passed runs = all 9,998 stable tests (each 10 successes) + 1 success in the flaky test
190+ PassedRuns : (9998 * 10 ) + 1 , // = 99,980 + 1 = 99,981
191+
192+ // Failed runs = the 1 failure in the flaky test
193+ FailedRuns : 1 ,
194+
195+ // No skipped
196+ SkippedRuns : 0 ,
197+
198+ // Pass ratio = 99,981 / 99,982 = 0.9999899 => 99.99899% => rounds to 100.00%
199+ PassRatio : "100.00%" ,
200+
201+ // Provided maxPassRatio
202+ MaxPassRatio : 1.0 ,
203+ },
204+ },
145205 }
146206
147207 for _ , tc := range tests {
0 commit comments