@@ -71,7 +71,7 @@ void setUp() throws Exception {
71
71
72
72
@ Test
73
73
void run_withoutJUnit_withOneSplit () throws Exception {
74
- final var splits = splitTests (1 , false );
74
+ final var splits = splitTests (1 , false , false );
75
75
assertThat (splits ).hasSize (1 ).containsExactly ( //
76
76
List .of ("de.donnerbart.example.FastTest" ,
77
77
"de.donnerbart.example.NoTimingOneTest" ,
@@ -83,7 +83,7 @@ void run_withoutJUnit_withOneSplit() throws Exception {
83
83
84
84
@ Test
85
85
void run_withoutJUnit_withTwoSplits () throws Exception {
86
- final var splits = splitTests (2 , false );
86
+ final var splits = splitTests (2 , false , false );
87
87
assertThat (splits ).hasSize (2 ).containsExactly ( //
88
88
List .of ("de.donnerbart.example.FastTest" ,
89
89
"de.donnerbart.example.NoTimingTwoTest" ,
@@ -94,7 +94,7 @@ void run_withoutJUnit_withTwoSplits() throws Exception {
94
94
95
95
@ Test
96
96
void run_withoutJUnit_withThreeSplits () throws Exception {
97
- final var splits = splitTests (3 , false );
97
+ final var splits = splitTests (3 , false , false );
98
98
assertThat (splits ).hasSize (3 ).containsExactly ( //
99
99
List .of ("de.donnerbart.example.FastTest" , "de.donnerbart.example.SlowTest" ),
100
100
List .of ("de.donnerbart.example.NoTimingOneTest" , "de.donnerbart.example.SlowestTest" ),
@@ -104,7 +104,7 @@ void run_withoutJUnit_withThreeSplits() throws Exception {
104
104
105
105
@ Test
106
106
void run_withoutJUnit_withThreeSplits_withGradleFormat () throws Exception {
107
- final var splits = splitTests (3 , false , "**/example-project/**/*Test.java" , tmp , FormatOption .GRADLE );
107
+ final var splits = splitTests (3 , false , "**/example-project/**/*Test.java" , false , tmp , FormatOption .GRADLE );
108
108
assertThat (splits ).hasSize (3 ).containsExactly ( //
109
109
List .of ("--tests de.donnerbart.example.FastTest" , "--tests de.donnerbart.example.SlowTest" ),
110
110
List .of ("--tests de.donnerbart.example.NoTimingOneTest" , "--tests de.donnerbart.example.SlowestTest" ),
@@ -114,7 +114,7 @@ void run_withoutJUnit_withThreeSplits_withGradleFormat() throws Exception {
114
114
115
115
@ Test
116
116
void run_withJUnit_withOneSplit () throws Exception {
117
- final var splits = splitTests (1 , true );
117
+ final var splits = splitTests (1 , true , false );
118
118
assertThat (splits ).hasSize (1 ).containsExactly ( //
119
119
List .of ("de.donnerbart.example.SlowestTest" ,
120
120
"de.donnerbart.example.SlowTest" ,
@@ -126,7 +126,7 @@ void run_withJUnit_withOneSplit() throws Exception {
126
126
127
127
@ Test
128
128
void run_withJUnit_withTwoSplits () throws Exception {
129
- final var splits = splitTests (2 , true );
129
+ final var splits = splitTests (2 , true , false );
130
130
assertThat (splits ).hasSize (2 ).containsExactly ( //
131
131
List .of ("de.donnerbart.example.SlowestTest" ),
132
132
List .of ("de.donnerbart.example.SlowTest" ,
@@ -138,7 +138,7 @@ void run_withJUnit_withTwoSplits() throws Exception {
138
138
139
139
@ Test
140
140
void run_withJUnit_withThreeSplits () throws Exception {
141
- final var splits = splitTests (3 , true );
141
+ final var splits = splitTests (3 , true , false );
142
142
assertThat (splits ).hasSize (3 ).containsExactly ( //
143
143
List .of ("de.donnerbart.example.SlowestTest" ),
144
144
List .of ("de.donnerbart.example.SlowTest" ),
@@ -150,7 +150,7 @@ void run_withJUnit_withThreeSplits() throws Exception {
150
150
151
151
@ Test
152
152
void run_withJUnit_withFourSplits () throws Exception {
153
- final var splits = splitTests (4 , true );
153
+ final var splits = splitTests (4 , true , false );
154
154
assertThat (splits ).hasSize (4 ).containsExactly ( //
155
155
List .of ("de.donnerbart.example.SlowestTest" ),
156
156
List .of ("de.donnerbart.example.SlowTest" ),
@@ -159,6 +159,51 @@ void run_withJUnit_withFourSplits() throws Exception {
159
159
assertThat (exitCode ).hasNullValue ();
160
160
}
161
161
162
+ @ Test
163
+ void run_withJUnit_withAverageTestTime_withOneSplit () throws Exception {
164
+ final var splits = splitTests (1 , true , true );
165
+ assertThat (splits ).hasSize (1 ).containsExactly ( //
166
+ List .of ("de.donnerbart.example.SlowestTest" ,
167
+ "de.donnerbart.example.NoTimingOneTest" ,
168
+ "de.donnerbart.example.NoTimingTwoTest" ,
169
+ "de.donnerbart.example.SlowTest" ,
170
+ "de.donnerbart.example.FastTest" ));
171
+ assertThat (exitCode ).hasNullValue ();
172
+ }
173
+
174
+ @ Test
175
+ void run_withJUnit_withAverageTestTime_withTwoSplits () throws Exception {
176
+ final var splits = splitTests (2 , true , true );
177
+ assertThat (splits ).hasSize (2 ).containsExactly ( //
178
+ List .of ("de.donnerbart.example.SlowestTest" ),
179
+ List .of ("de.donnerbart.example.NoTimingOneTest" ,
180
+ "de.donnerbart.example.NoTimingTwoTest" ,
181
+ "de.donnerbart.example.SlowTest" ,
182
+ "de.donnerbart.example.FastTest" ));
183
+ assertThat (exitCode ).hasNullValue ();
184
+ }
185
+
186
+ @ Test
187
+ void run_withJUnit_withAverageTestTime_withThreeSplits () throws Exception {
188
+ final var splits = splitTests (3 , true , true );
189
+ assertThat (splits ).hasSize (3 ).containsExactly ( //
190
+ List .of ("de.donnerbart.example.SlowestTest" ),
191
+ List .of ("de.donnerbart.example.NoTimingOneTest" , "de.donnerbart.example.SlowTest" ),
192
+ List .of ("de.donnerbart.example.NoTimingTwoTest" , "de.donnerbart.example.FastTest" ));
193
+ assertThat (exitCode ).hasNullValue ();
194
+ }
195
+
196
+ @ Test
197
+ void run_withJUnit_withAverageTestTime_withFourSplits () throws Exception {
198
+ final var splits = splitTests (4 , true , true );
199
+ assertThat (splits ).hasSize (4 ).containsExactly ( //
200
+ List .of ("de.donnerbart.example.SlowestTest" ),
201
+ List .of ("de.donnerbart.example.NoTimingOneTest" ),
202
+ List .of ("de.donnerbart.example.NoTimingTwoTest" ),
203
+ List .of ("de.donnerbart.example.SlowTest" , "de.donnerbart.example.FastTest" ));
204
+ assertThat (exitCode ).hasNullValue ();
205
+ }
206
+
162
207
@ Test
163
208
void run_whitespaceClassDefinition () throws Exception {
164
209
final var projectFolder =
@@ -174,6 +219,7 @@ void run_whitespaceClassDefinition() throws Exception {
174
219
null ,
175
220
null ,
176
221
FormatOption .LIST ,
222
+ false ,
177
223
projectFolder ,
178
224
true ,
179
225
exitCode ::set );
@@ -191,8 +237,12 @@ void run_thirdPartyLibrary() throws Exception {
191
237
"ThirdPartyLibraryTest.java" ,
192
238
PERMISSIONS );
193
239
194
- final var splits =
195
- splitTests (1 , false , "**/third-party-library-project/**/*Test.java" , projectFolder , FormatOption .LIST );
240
+ final var splits = splitTests (1 ,
241
+ false ,
242
+ "**/third-party-library-project/**/*Test.java" ,
243
+ false ,
244
+ projectFolder ,
245
+ FormatOption .LIST );
196
246
assertThat (splits ).hasSize (1 ).containsExactly (List .of ("de.donnerbart.example.ThirdPartyLibraryTest" ));
197
247
assertThat (exitCode ).hasNullValue ();
198
248
}
@@ -203,7 +253,7 @@ void run_noPackage() throws Exception {
203
253
copyResourceToTarget (projectFolder , "tests/NoPackageTest.java" , "NoPackageTest.java" , PERMISSIONS );
204
254
205
255
final var splits =
206
- splitTests (1 , false , "**/no-package-project/**/*Test.java" , projectFolder , FormatOption .LIST );
256
+ splitTests (1 , false , "**/no-package-project/**/*Test.java" , false , projectFolder , FormatOption .LIST );
207
257
assertThat (splits ).hasSize (1 ).containsExactly (List .of ("NoPackageTest" ));
208
258
assertThat (exitCode ).hasNullValue ();
209
259
}
@@ -213,7 +263,19 @@ void run_noTests() throws Exception {
213
263
final var projectFolder = tmp .resolve ("no-tests-project" ).resolve ("src" ).resolve ("main" ).resolve ("java" );
214
264
Files .createDirectories (projectFolder );
215
265
216
- final var splits = splitTests (1 , false , "**/no-tests-project/**/*Test.java" , projectFolder , FormatOption .LIST );
266
+ final var splits =
267
+ splitTests (1 , false , "**/no-tests-project/**/*Test.java" , false , projectFolder , FormatOption .LIST );
268
+ assertThat (splits ).hasSize (1 ).containsExactly (List .of ());
269
+ assertThat (exitCode ).hasValue (1 );
270
+ }
271
+
272
+ @ Test
273
+ void run_noTests_withAverageTestTime () throws Exception {
274
+ final var projectFolder = tmp .resolve ("no-tests-project" ).resolve ("src" ).resolve ("main" ).resolve ("java" );
275
+ Files .createDirectories (projectFolder );
276
+
277
+ final var splits =
278
+ splitTests (1 , false , "**/no-tests-project/**/*Test.java" , true , projectFolder , FormatOption .LIST );
217
279
assertThat (splits ).hasSize (1 ).containsExactly (List .of ());
218
280
assertThat (exitCode ).hasValue (1 );
219
281
}
@@ -224,19 +286,28 @@ void run_noClassName() throws Exception {
224
286
copyResourceToTarget (projectFolder , "tests/NoClassNameTest.java" , "NoClassNameTest.java" , PERMISSIONS );
225
287
226
288
final var splits =
227
- splitTests (1 , false , "**/no-classname-project/**/*Test.java" , projectFolder , FormatOption .LIST );
289
+ splitTests (1 , false , "**/no-classname-project/**/*Test.java" , false , projectFolder , FormatOption .LIST );
228
290
assertThat (splits ).hasSize (1 ).containsExactly (List .of ());
229
291
assertThat (exitCode ).hasValue (1 );
230
292
}
231
293
232
- private @ NotNull List <List <String >> splitTests (final int splitTotal , final boolean withJUnit ) throws Exception {
233
- return splitTests (splitTotal , withJUnit , "**/example-project/**/*Test.java" , tmp , FormatOption .LIST );
294
+ private @ NotNull List <List <String >> splitTests (
295
+ final int splitTotal ,
296
+ final boolean withJUnit ,
297
+ final boolean useAverageTimeForNewTests ) throws Exception {
298
+ return splitTests (splitTotal ,
299
+ withJUnit ,
300
+ "**/example-project/**/*Test.java" ,
301
+ useAverageTimeForNewTests ,
302
+ tmp ,
303
+ FormatOption .LIST );
234
304
}
235
305
236
306
private @ NotNull List <List <String >> splitTests (
237
307
final int splitTotal ,
238
308
final boolean withJUnit ,
239
309
final @ NotNull String glob ,
310
+ final boolean useAverageTimeForNewTests ,
240
311
final @ NotNull Path workingDir ,
241
312
final @ NotNull FormatOption format ) throws Exception {
242
313
final var splits = new ArrayList <List <String >>();
@@ -247,6 +318,7 @@ void run_noClassName() throws Exception {
247
318
"**/example-project/**/*Abstract*.java" ,
248
319
withJUnit ? "**/junit-reports/*.xml" : null ,
249
320
format ,
321
+ useAverageTimeForNewTests ,
250
322
workingDir ,
251
323
true ,
252
324
exitCode ::set );
0 commit comments