Skip to content

Commit 9bc6c54

Browse files
committed
Add temporary ErrorSpecNode until it is handled by the platform
1 parent d4e721a commit 9bc6c54

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Diff for: spock-core/src/main/java/org/spockframework/runtime/ClassSelectorResolver.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ private Resolution resolveClass(Class<?> specClass, Context context) {
4949
return context
5050
.addToParent(parent -> {
5151
UniqueId uniqueId = parent.getUniqueId().append("spec", specInfo.getReflection().getName());
52-
runContext.createExtensionRunner(specInfo).run();
52+
try {
53+
runContext.createExtensionRunner(specInfo).run();
54+
} catch (Exception e) {
55+
// TODO revisit, this should be handled on the platform level
56+
return Optional.of(new ErrorSpecNode(uniqueId, specInfo, e));
57+
}
5358
return Optional.of(new SpecNode(uniqueId, specInfo));
5459
})
5560
.map(specNode -> toResolution(specInfo, specNode))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.spockframework.runtime;
2+
3+
import org.spockframework.runtime.model.SpecInfo;
4+
import org.spockframework.util.ExceptionUtil;
5+
6+
import org.junit.platform.engine.UniqueId;
7+
8+
public class ErrorSpecNode extends SpecNode {
9+
private final Throwable error;
10+
11+
protected ErrorSpecNode(UniqueId uniqueId, SpecInfo specInfo, Throwable error) {
12+
super(uniqueId, specInfo);
13+
this.error = error;
14+
}
15+
16+
@Override
17+
public SpockExecutionContext execute(SpockExecutionContext context, DynamicTestExecutor dynamicTestExecutor) throws Exception {
18+
ExceptionUtil.sneakyThrow(error);
19+
return null; //
20+
}
21+
}

0 commit comments

Comments
 (0)