From e82457ec05f80adddc4b3b87bb992dd2079109f9 Mon Sep 17 00:00:00 2001 From: zentox Date: Wed, 13 Dec 2023 10:19:08 +0100 Subject: [PATCH] Use JUnit timeouts instead of Jagr --- build.gradle.kts | 29 ++++++++++++++----- .../java/h06/H1_DirectionVectorTest.java | 2 ++ src/graderPrivate/java/h06/H2_WorldTest.java | 2 ++ .../java/h06/H3_MazeSolverRecursiveTest.java | 2 ++ .../java/h06/H4_MazeSolverIterativeTest.java | 2 ++ src/graderPrivate/java/h06/TestConstants.java | 5 ++++ 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index fd4f2cd..b2582ab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,24 +17,39 @@ jagr { } } graders { - val graderPublic by creating { - graderName.set("H06-Public") + val graderPrivate by creating { + graderName.set("H06-Private") rubricProviderName.set("h06.H06_RubricProvider") + config.set( + org.sourcegrade.jagr.launcher.env.Config( + executor = org.sourcegrade.jagr.launcher.env.Executor( + jvmArgs = listOf( + "-Djava.awt.headless=true", + "-Dtestfx.robot=glass", + "-Dtestfx.headless=true", + "-Dprism.order=sw", + "-Dprism.lcdtext=false", + "-Dprism.subpixeltext=false", + "-Dglass.win.uiScale=100%", + "-Dprism.text=t2k", + ), + ), + transformers = org.sourcegrade.jagr.launcher.env.Transformers( + timeout = org.sourcegrade.jagr.launcher.env.Transformers.TimeoutTransformer(enabled = false), + ), + ), + ) configureDependencies { implementation(libs.algoutils.tutor) + implementation(libs.bundles.junit) } } - val graderPrivate by creating { - parent(graderPublic) - graderName.set("H06-Private") - } } } dependencies { implementation(libs.annotations) implementation(libs.algoutils.student) - testImplementation(libs.bundles.junit) testImplementation(libs.junit.core) implementation(libs.fopbot) } diff --git a/src/graderPrivate/java/h06/H1_DirectionVectorTest.java b/src/graderPrivate/java/h06/H1_DirectionVectorTest.java index 7cb2b18..3d88b0f 100644 --- a/src/graderPrivate/java/h06/H1_DirectionVectorTest.java +++ b/src/graderPrivate/java/h06/H1_DirectionVectorTest.java @@ -11,6 +11,7 @@ import org.junitpioneer.jupiter.json.JsonClasspathSource; import org.junitpioneer.jupiter.json.Property; import org.sourcegrade.jagr.api.rubric.TestForSubmission; +import org.tudalgo.algoutils.tutor.general.annotation.SkipAfterFirstFailedTest; import org.tudalgo.algoutils.tutor.general.assertions.Context; import org.tudalgo.algoutils.tutor.general.reflections.BasicMethodLink; import org.tudalgo.algoutils.tutor.general.reflections.MethodLink; @@ -43,6 +44,7 @@ unit = TimeUnit.SECONDS, threadMode = Timeout.ThreadMode.SEPARATE_THREAD ) +@SkipAfterFirstFailedTest(TestConstants.SKIP_AFTER_FIRST_FAILED_TEST) public class H1_DirectionVectorTest { /** diff --git a/src/graderPrivate/java/h06/H2_WorldTest.java b/src/graderPrivate/java/h06/H2_WorldTest.java index 0eb0617..e2b5648 100644 --- a/src/graderPrivate/java/h06/H2_WorldTest.java +++ b/src/graderPrivate/java/h06/H2_WorldTest.java @@ -10,6 +10,7 @@ import org.junitpioneer.jupiter.json.JsonClasspathSource; import org.junitpioneer.jupiter.json.Property; import org.sourcegrade.jagr.api.rubric.TestForSubmission; +import org.tudalgo.algoutils.tutor.general.annotation.SkipAfterFirstFailedTest; import org.tudalgo.algoutils.tutor.general.assertions.Context; import org.tudalgo.algoutils.tutor.general.match.BasicReflectionMatchers; import org.tudalgo.algoutils.tutor.general.reflections.BasicTypeLink; @@ -36,6 +37,7 @@ unit = TimeUnit.SECONDS, threadMode = Timeout.ThreadMode.SEPARATE_THREAD ) +@SkipAfterFirstFailedTest(TestConstants.SKIP_AFTER_FIRST_FAILED_TEST) public class H2_WorldTest { /** diff --git a/src/graderPrivate/java/h06/H3_MazeSolverRecursiveTest.java b/src/graderPrivate/java/h06/H3_MazeSolverRecursiveTest.java index 7d2c14c..126d448 100644 --- a/src/graderPrivate/java/h06/H3_MazeSolverRecursiveTest.java +++ b/src/graderPrivate/java/h06/H3_MazeSolverRecursiveTest.java @@ -17,6 +17,7 @@ import org.junitpioneer.jupiter.json.Property; import org.opentest4j.AssertionFailedError; import org.sourcegrade.jagr.api.rubric.TestForSubmission; +import org.tudalgo.algoutils.tutor.general.annotation.SkipAfterFirstFailedTest; import org.tudalgo.algoutils.tutor.general.assertions.Context; import org.tudalgo.algoutils.tutor.general.reflections.BasicMethodLink; import org.tudalgo.algoutils.tutor.general.reflections.MethodLink; @@ -59,6 +60,7 @@ unit = TimeUnit.SECONDS, threadMode = Timeout.ThreadMode.SEPARATE_THREAD ) +@SkipAfterFirstFailedTest(TestConstants.SKIP_AFTER_FIRST_FAILED_TEST) public class H3_MazeSolverRecursiveTest { /** diff --git a/src/graderPrivate/java/h06/H4_MazeSolverIterativeTest.java b/src/graderPrivate/java/h06/H4_MazeSolverIterativeTest.java index fd94402..ab5e5ba 100644 --- a/src/graderPrivate/java/h06/H4_MazeSolverIterativeTest.java +++ b/src/graderPrivate/java/h06/H4_MazeSolverIterativeTest.java @@ -16,6 +16,7 @@ import org.junitpioneer.jupiter.json.JsonClasspathSource; import org.junitpioneer.jupiter.json.Property; import org.sourcegrade.jagr.api.rubric.TestForSubmission; +import org.tudalgo.algoutils.tutor.general.annotation.SkipAfterFirstFailedTest; import org.tudalgo.algoutils.tutor.general.assertions.Context; import org.tudalgo.algoutils.tutor.general.reflections.BasicMethodLink; import org.tudalgo.algoutils.tutor.general.reflections.MethodLink; @@ -49,6 +50,7 @@ unit = TimeUnit.SECONDS, threadMode = Timeout.ThreadMode.SEPARATE_THREAD ) +@SkipAfterFirstFailedTest(TestConstants.SKIP_AFTER_FIRST_FAILED_TEST) public class H4_MazeSolverIterativeTest { /** diff --git a/src/graderPrivate/java/h06/TestConstants.java b/src/graderPrivate/java/h06/TestConstants.java index 6964623..5235736 100644 --- a/src/graderPrivate/java/h06/TestConstants.java +++ b/src/graderPrivate/java/h06/TestConstants.java @@ -9,4 +9,9 @@ public class TestConstants { * The timeout for each test in seconds. */ public static final int TEST_TIMEOUT_IN_SECONDS = 2; + + /** + * Whether to skip the remaining parametrized tests after the first failed test. + */ + public static final boolean SKIP_AFTER_FIRST_FAILED_TEST = true; }