From d92fef432eb85ca1f30f033db5196c1d889f2225 Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Thu, 21 Mar 2024 14:42:48 +0100 Subject: [PATCH] SINT: Expose the test that's being executed --- .../SmackIntegrationTestFramework.java | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java index 8be908fb0..60b39db36 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java @@ -87,6 +87,8 @@ public class SmackIntegrationTestFramework { public static boolean SINTTEST_UNIT_TEST = false; + private static ConcreteTest TEST_UNDER_EXECUTION; + protected final Configuration config; protected TestRunResult testRunResult; @@ -244,6 +246,10 @@ public class SmackIntegrationTestFramework { return testRunResult; } + public static ConcreteTest getTestUnderExecution() { + return TEST_UNDER_EXECUTION; + } + @SuppressWarnings({"Finally"}) private void runTests(Set> classes) throws InterruptedException, InstantiationException, IllegalAccessException, @@ -680,7 +686,12 @@ public class SmackIntegrationTestFramework { executeSinttestSpecialMethod(beforeClassMethod); for (ConcreteTest concreteTest : concreteTests) { - runConcreteTest(concreteTest); + TEST_UNDER_EXECUTION = concreteTest; + try { + runConcreteTest(concreteTest); + } finally { + TEST_UNDER_EXECUTION = null; + } } } finally { @@ -729,21 +740,33 @@ public class SmackIntegrationTestFramework { return null; } - static final class ConcreteTest { + public static final class ConcreteTest { private final TestType testType; private final Method method; private final Executor executor; - private final String[] subdescriptons; + private final List subdescriptons; private ConcreteTest(TestType testType, Method method, Executor executor, String... subdescriptions) { this.testType = testType; this.method = method; this.executor = executor; - this.subdescriptons = subdescriptions; + this.subdescriptons = List.of(subdescriptions); } private transient String stringCache; + public TestType getTestType() { + return testType; + } + + public Method getMethod() { + return method; + } + + public List getSubdescriptons() { + return subdescriptons; + } + @Override public String toString() { if (stringCache != null) { @@ -756,9 +779,9 @@ public class SmackIntegrationTestFramework { .append(method.getName()) .append(" (") .append(testType.name()); - if (subdescriptons != null && subdescriptons.length > 0) { + if (!subdescriptons.isEmpty()) { sb.append(", "); - StringUtils.appendTo(Arrays.asList(subdescriptons), sb); + StringUtils.appendTo(subdescriptons, sb); } sb.append(')');