@@ -63,14 +63,21 @@ public function report(SlowTestList $slowTestList): string
6363 */
6464 private function lines (SlowTestList $ slowTestList ): \Generator
6565 {
66+ $ durationFormatter = $ this ->durationFormatter ;
67+ $ formattedMaximumGlobalDuration = $ durationFormatter ->format ($ this ->maximumDuration );
68+
6669 $ slowTestCount = $ slowTestList ->count ();
6770
6871 if ($ slowTestCount ->equals (Count::fromInt (1 ))) {
69- yield 'Detected 1 test where the duration exceeded the maximum duration. ' ;
72+ yield \sprintf (
73+ 'Detected 1 test where the duration exceeded the maximum duration (%s). ' ,
74+ $ formattedMaximumGlobalDuration
75+ );
7076 } else {
7177 yield \sprintf (
72- 'Detected %d tests where the duration exceeded the maximum duration. ' ,
73- $ slowTestCount ->toInt ()
78+ 'Detected %d tests where the duration exceeded the maximum duration (%s). ' ,
79+ $ slowTestCount ->toInt (),
80+ $ formattedMaximumGlobalDuration
7481 );
7582 }
7683
@@ -88,23 +95,40 @@ private function lines(SlowTestList $slowTestList): \Generator
8895 $ durationWidth = \strlen ($ this ->durationFormatter ->format ($ slowTestWithLongestDuration ->duration ()));
8996 $ maximumDurationWidth = \strlen ($ this ->durationFormatter ->format ($ slowTestWithLongestMaximumDuration ->maximumDuration ()->toDuration ()));
9097
91- $ template = \sprintf (
92- '%%%dd. %%%ds (%%%ds) %%s ' ,
93- $ numberWidth ,
94- $ durationWidth ,
95- $ maximumDurationWidth
96- );
97-
9898 $ number = 1 ;
9999
100100 foreach ($ slowTestListThatWillBeReported ->toArray () as $ slowTest ) {
101- yield \sprintf (
102- $ template ,
103- (string ) $ number ,
104- $ this ->durationFormatter ->format ($ slowTest ->duration ()),
105- $ this ->durationFormatter ->format ($ slowTest ->maximumDuration ()->toDuration ()),
106- $ slowTest ->testDescription ()->toString ()
107- );
101+ $ formattedMaximumDuration = $ this ->durationFormatter ->format ($ slowTest ->duration ());
102+
103+ if ($ formattedMaximumDuration === $ formattedMaximumGlobalDuration ) {
104+ $ template = \sprintf (
105+ '%%%dd. %%%ds %%s ' ,
106+ $ numberWidth ,
107+ $ durationWidth
108+ );
109+
110+ yield \sprintf (
111+ $ template ,
112+ (string ) $ number ,
113+ $ this ->durationFormatter ->format ($ slowTest ->duration ()),
114+ $ slowTest ->testDescription ()->toString ()
115+ );
116+ } else {
117+ $ template = \sprintf (
118+ '%%%dd. %%%ds (%%%ds) %%s ' ,
119+ $ numberWidth ,
120+ $ durationWidth ,
121+ $ maximumDurationWidth
122+ );
123+
124+ yield \sprintf (
125+ $ template ,
126+ (string ) $ number ,
127+ $ this ->durationFormatter ->format ($ slowTest ->duration ()),
128+ $ formattedMaximumDuration ,
129+ $ slowTest ->testDescription ()->toString ()
130+ );
131+ }
108132
109133 ++$ number ;
110134 }
0 commit comments