Skip to content

Commit 282ba81

Browse files
committed
support handleFlaky with tests
1 parent 565de8a commit 282ba81

2 files changed

Lines changed: 38 additions & 16 deletions

File tree

core-tests/e2e-tests/e2e-tests-utils/src/test/java/org/evomaster/e2etests/utils/EnterpriseTestBase.java

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected void runTestHandlingFlaky(
207207
Consumer<List<String>> lambda,
208208
int timeoutMinutes) throws Throwable{
209209

210-
runTestHandlingFlaky(outputFolderName, fullClassName, null, iterations, createTests, lambda, timeoutMinutes);
210+
runTestHandlingFlaky(outputFolderName, fullClassName, null, iterations, createTests, false, lambda, timeoutMinutes);
211211
}
212212

213213
protected void runTestHandlingFlaky(
@@ -216,6 +216,7 @@ protected void runTestHandlingFlaky(
216216
List<String> terminations,
217217
int iterations,
218218
boolean createTests,
219+
boolean handleFlakyWithTests,
219220
Consumer<List<String>> lambda,
220221
int timeoutMinutes) throws Throwable{
221222
List<ClassName> classNames = new ArrayList<>();
@@ -246,6 +247,9 @@ protected void runTestHandlingFlaky(
246247
List<String> args = getArgsWithCompilation(iterations, outputFolderName, className, createTests, finalSplitType, "FALSE");
247248
defaultSeed++;
248249
lambda.accept(new ArrayList<>(args));
250+
251+
if (createTests && handleFlakyWithTests)
252+
runTests(outputFolderName, fullClassName, terminations);
249253
}
250254
);
251255
});
@@ -257,7 +261,7 @@ protected void runTestHandlingFlakyAndCompilation(
257261
int timeoutMinutes,
258262
Consumer<List<String>> lambda) throws Throwable {
259263

260-
runTestHandlingFlakyAndCompilation(label, "org.bar."+label, null, iterations, true, lambda, timeoutMinutes);
264+
runTestHandlingFlakyAndCompilation(label, "org.bar."+label, null, iterations, true, false, lambda, timeoutMinutes);
261265
}
262266

263267
protected void runTestHandlingFlakyAndCompilation(
@@ -275,7 +279,17 @@ protected void runTestHandlingFlakyAndCompilation(
275279
int iterations,
276280
Consumer<List<String>> lambda) throws Throwable {
277281

278-
runTestHandlingFlakyAndCompilation(outputFolderName, fullClassName, null, iterations, true, lambda, 3);
282+
runTestHandlingFlakyAndCompilation(outputFolderName, fullClassName, null, iterations, true, false, lambda, 3);
283+
}
284+
285+
protected void runTestHandlingFlakyAndCompilation(
286+
String outputFolderName,
287+
String fullClassName,
288+
int iterations,
289+
boolean handleFlakyWithTests,
290+
Consumer<List<String>> lambda) throws Throwable {
291+
292+
runTestHandlingFlakyAndCompilation(outputFolderName, fullClassName, null, iterations, true, handleFlakyWithTests, lambda, 3);
279293
}
280294

281295
protected void runTestHandlingFlakyAndCompilation(
@@ -285,7 +299,7 @@ protected void runTestHandlingFlakyAndCompilation(
285299
int iterations,
286300
Consumer<List<String>> lambda) throws Throwable {
287301

288-
runTestHandlingFlakyAndCompilation(outputFolderName, fullClassName, terminations, iterations, true, lambda, 3);
302+
runTestHandlingFlakyAndCompilation(outputFolderName, fullClassName, terminations, iterations, true, false, lambda, 3);
289303
}
290304

291305
protected void runTestHandlingFlakyAndCompilation(
@@ -294,24 +308,31 @@ protected void runTestHandlingFlakyAndCompilation(
294308
List<String> terminations,
295309
int iterations,
296310
boolean createTests,
311+
boolean handleFlakyWithTests,
297312
Consumer<List<String>> lambda,
298313
int timeoutMinutes) throws Throwable {
299314

300-
runTestHandlingFlaky(outputFolderName, fullClassName, terminations, iterations, createTests,lambda, timeoutMinutes);
315+
runTestHandlingFlaky(outputFolderName, fullClassName, terminations, iterations, createTests, false, lambda, timeoutMinutes);
301316

302317
if (terminations == null) terminations = Arrays.asList("");
303318
//BMR: this is where I should handle multiples???
304-
if (createTests){
305-
MethodReplacementPreserveSemantics.shouldPreserveSemantics = true;
319+
if (createTests && !handleFlakyWithTests){
320+
runTests(outputFolderName, fullClassName, terminations);
321+
}
322+
}
306323

307-
for (String termination : terminations) {
308-
assertTimeoutPreemptively(Duration.ofMinutes(2), () -> {
309-
ClassName className = new ClassName(fullClassName + termination);
310-
clearCompiledFiles(className);
311-
//the first one goes through, but for the second generated files appear to not be clean.
312-
compileRunAndVerifyTests(outputFolderName, className);
313-
});
314-
}
324+
protected void runTests(String outputFolderName,
325+
String fullClassName,
326+
List<String> terminations){
327+
MethodReplacementPreserveSemantics.shouldPreserveSemantics = true;
328+
329+
for (String termination : terminations) {
330+
assertTimeoutPreemptively(Duration.ofMinutes(2), () -> {
331+
ClassName className = new ClassName(fullClassName + termination);
332+
clearCompiledFiles(className);
333+
//the first one goes through, but for the second generated files appear to not be clean.
334+
compileRunAndVerifyTests(outputFolderName, className);
335+
});
315336
}
316337
}
317338

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/flakinessdetect/FlakinessDetectBlackboxEMTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class FlakinessDetectBlackboxEMTest : SpringTestBase() {
2929
runTestHandlingFlakyAndCompilation(
3030
outputFolder,
3131
outputClass,
32-
2000
32+
2000,
33+
true,
3334
) { args: MutableList<String> ->
3435

3536

0 commit comments

Comments
 (0)