@@ -55,14 +55,21 @@ public function report(SlowTestList $slowTestList): string
5555 */
5656 private function lines (SlowTestList $ slowTestList ): \Generator
5757 {
58+ $ durationFormatter = $ this ->durationFormatter ;
59+ $ formattedMaximumGlobalDuration = $ durationFormatter ->format ($ this ->maximumDuration );
60+
5861 $ slowTestCount = $ slowTestList ->count ();
5962
6063 if ($ slowTestCount ->equals (Count::fromInt (1 ))) {
61- yield 'Detected 1 test where the duration exceeded the maximum duration. ' ;
64+ yield \sprintf (
65+ 'Detected 1 test where the duration exceeded the maximum duration (%s). ' ,
66+ $ formattedMaximumGlobalDuration
67+ );
6268 } else {
6369 yield \sprintf (
64- 'Detected %d tests where the duration exceeded the maximum duration. ' ,
65- $ slowTestCount ->toInt ()
70+ 'Detected %d tests where the duration exceeded the maximum duration (%s). ' ,
71+ $ slowTestCount ->toInt (),
72+ $ formattedMaximumGlobalDuration
6673 );
6774 }
6875
@@ -80,23 +87,40 @@ private function lines(SlowTestList $slowTestList): \Generator
8087 $ durationWidth = \strlen ($ this ->durationFormatter ->format ($ slowTestWithLongestDuration ->duration ()));
8188 $ maximumDurationWidth = \strlen ($ this ->durationFormatter ->format ($ slowTestWithLongestMaximumDuration ->maximumDuration ()->toDuration ()));
8289
83- $ template = \sprintf (
84- '%%%dd. %%%ds (%%%ds) %%s ' ,
85- $ numberWidth ,
86- $ durationWidth ,
87- $ maximumDurationWidth
88- );
89-
9090 $ number = 1 ;
9191
9292 foreach ($ slowTestListThatWillBeReported ->toArray () as $ slowTest ) {
93- yield \sprintf (
94- $ template ,
95- (string ) $ number ,
96- $ this ->durationFormatter ->format ($ slowTest ->duration ()),
97- $ this ->durationFormatter ->format ($ slowTest ->maximumDuration ()->toDuration ()),
98- $ slowTest ->testDescription ()->toString ()
99- );
93+ $ formattedMaximumDuration = $ this ->durationFormatter ->format ($ slowTest ->duration ());
94+
95+ if ($ formattedMaximumDuration === $ formattedMaximumGlobalDuration ) {
96+ $ template = \sprintf (
97+ '%%%dd. %%%ds %%s ' ,
98+ $ numberWidth ,
99+ $ durationWidth
100+ );
101+
102+ yield \sprintf (
103+ $ template ,
104+ (string ) $ number ,
105+ $ this ->durationFormatter ->format ($ slowTest ->duration ()),
106+ $ slowTest ->testDescription ()->toString ()
107+ );
108+ } else {
109+ $ template = \sprintf (
110+ '%%%dd. %%%ds (%%%ds) %%s ' ,
111+ $ numberWidth ,
112+ $ durationWidth ,
113+ $ maximumDurationWidth
114+ );
115+
116+ yield \sprintf (
117+ $ template ,
118+ (string ) $ number ,
119+ $ this ->durationFormatter ->format ($ slowTest ->duration ()),
120+ $ formattedMaximumDuration ,
121+ $ slowTest ->testDescription ()->toString ()
122+ );
123+ }
100124
101125 ++$ number ;
102126 }
0 commit comments