org.lockss.util.test.VariantTestInvocationContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lockss-util Show documentation
Show all versions of lockss-util Show documentation
Development and testing utilities common to most LOCKSS projects
The newest version!
package org.lockss.util.test;
import java.util.*;
import org.junit.jupiter.api.extension.*;
class VariantTestInvocationContext implements TestTemplateInvocationContext {
private final VariantTestNameFormatter formatter;
private final String vName;
VariantTestInvocationContext(VariantTestNameFormatter formatter,
String vName) {
this.formatter = formatter;
this.vName = vName;
}
@Override
public String getDisplayName(int invocationIndex) {
return this.formatter.format(invocationIndex, this.vName);
}
@Override
public List getAdditionalExtensions() {
return Collections.singletonList(new BeforeEachCallback() {
@Override
public void beforeEach(ExtensionContext context) {
// log.info("beforeEach: " + context);
// log.info("testInstance: " + context.getTestInstance());
Optional optInst = context.getTestInstance();
if (optInst.isPresent()) {
LockssTestCase5 ltc5 = (LockssTestCase5)optInst.get();
// log.info("setUpVariant: " + vName);
ltc5.setUpVariant(vName);
}
}
});
}
}