Skip to content

Commit

Permalink
SINT: Expose the test that's being executed
Browse files Browse the repository at this point in the history
  • Loading branch information
guusdk committed Apr 3, 2024
1 parent e504bc2 commit d92fef4
Showing 1 changed file with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -244,6 +246,10 @@ public synchronized TestRunResult run()
return testRunResult;
}

public static ConcreteTest getTestUnderExecution() {
return TEST_UNDER_EXECUTION;
}

@SuppressWarnings({"Finally"})
private void runTests(Set<Class<? extends AbstractSmackIntTest>> classes)
throws InterruptedException, InstantiationException, IllegalAccessException,
Expand Down Expand Up @@ -680,7 +686,12 @@ public void run() throws InterruptedException, XMPPException, IOException, Smack
executeSinttestSpecialMethod(beforeClassMethod);

for (ConcreteTest concreteTest : concreteTests) {
runConcreteTest(concreteTest);
TEST_UNDER_EXECUTION = concreteTest;
try {
runConcreteTest(concreteTest);
} finally {
TEST_UNDER_EXECUTION = null;
}
}
}
finally {
Expand Down Expand Up @@ -729,21 +740,33 @@ else if (specialClassMethods.size() > 1) {
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<String> 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<String> getSubdescriptons() {
return subdescriptons;
}

@Override
public String toString() {
if (stringCache != null) {
Expand All @@ -756,9 +779,9 @@ public String toString() {
.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(')');

Expand Down

0 comments on commit d92fef4

Please sign in to comment.