package org.junit.jupiter.engine.descriptor;
import org.junit.jupiter.api.DynamicNode;
import org.junit.jupiter.engine.config.JupiterConfiguration;
import org.junit.jupiter.engine.execution.JupiterEngineExecutionContext;
import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.TestSource;
import org.junit.platform.engine.UniqueId;
abstract class DynamicNodeTestDescriptor extends JupiterTestDescriptor {
private final int index;
DynamicNodeTestDescriptor(UniqueId uniqueId, int index, DynamicNode dynamicNode, TestSource testSource,
JupiterConfiguration configuration) {
super(uniqueId, dynamicNode.getDisplayName(), testSource, configuration);
this.index = index;
}
@Override
public String getLegacyReportingName() {
return getParent()
.map(TestDescriptor::getLegacyReportingName)
.orElseGet(this::getDisplayName)
+ "[" + index + "]";
}
@Override
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context) {
DynamicExtensionContext extensionContext = new DynamicExtensionContext(context.getExtensionContext(),
context.getExecutionListener(), this, context.getConfiguration());
return context.extend()
.withExtensionContext(extensionContext)
.build();
}
@Override
public SkipResult shouldBeSkipped(JupiterEngineExecutionContext context) {
return SkipResult.doNotSkip();
}
}