1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-10-18 20:25:59 +02:00

SINT: Expose the test that's being executed

This commit is contained in:
Guus der Kinderen 2024-03-21 14:42:48 +01:00
parent e504bc23cf
commit d92fef432e

View file

@ -87,6 +87,8 @@ public class SmackIntegrationTestFramework {
public static boolean SINTTEST_UNIT_TEST = false; public static boolean SINTTEST_UNIT_TEST = false;
private static ConcreteTest TEST_UNDER_EXECUTION;
protected final Configuration config; protected final Configuration config;
protected TestRunResult testRunResult; protected TestRunResult testRunResult;
@ -244,6 +246,10 @@ public class SmackIntegrationTestFramework {
return testRunResult; return testRunResult;
} }
public static ConcreteTest getTestUnderExecution() {
return TEST_UNDER_EXECUTION;
}
@SuppressWarnings({"Finally"}) @SuppressWarnings({"Finally"})
private void runTests(Set<Class<? extends AbstractSmackIntTest>> classes) private void runTests(Set<Class<? extends AbstractSmackIntTest>> classes)
throws InterruptedException, InstantiationException, IllegalAccessException, throws InterruptedException, InstantiationException, IllegalAccessException,
@ -680,7 +686,12 @@ public class SmackIntegrationTestFramework {
executeSinttestSpecialMethod(beforeClassMethod); executeSinttestSpecialMethod(beforeClassMethod);
for (ConcreteTest concreteTest : concreteTests) { for (ConcreteTest concreteTest : concreteTests) {
TEST_UNDER_EXECUTION = concreteTest;
try {
runConcreteTest(concreteTest); runConcreteTest(concreteTest);
} finally {
TEST_UNDER_EXECUTION = null;
}
} }
} }
finally { finally {
@ -729,21 +740,33 @@ public class SmackIntegrationTestFramework {
return null; return null;
} }
static final class ConcreteTest { public static final class ConcreteTest {
private final TestType testType; private final TestType testType;
private final Method method; private final Method method;
private final Executor executor; private final Executor executor;
private final String[] subdescriptons; private final List<String> subdescriptons;
private ConcreteTest(TestType testType, Method method, Executor executor, String... subdescriptions) { private ConcreteTest(TestType testType, Method method, Executor executor, String... subdescriptions) {
this.testType = testType; this.testType = testType;
this.method = method; this.method = method;
this.executor = executor; this.executor = executor;
this.subdescriptons = subdescriptions; this.subdescriptons = List.of(subdescriptions);
} }
private transient String stringCache; private transient String stringCache;
public TestType getTestType() {
return testType;
}
public Method getMethod() {
return method;
}
public List<String> getSubdescriptons() {
return subdescriptons;
}
@Override @Override
public String toString() { public String toString() {
if (stringCache != null) { if (stringCache != null) {
@ -756,9 +779,9 @@ public class SmackIntegrationTestFramework {
.append(method.getName()) .append(method.getName())
.append(" (") .append(" (")
.append(testType.name()); .append(testType.name());
if (subdescriptons != null && subdescriptons.length > 0) { if (!subdescriptons.isEmpty()) {
sb.append(", "); sb.append(", ");
StringUtils.appendTo(Arrays.asList(subdescriptons), sb); StringUtils.appendTo(subdescriptons, sb);
} }
sb.append(')'); sb.append(')');