All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lockss.util.test.VariantTestInvocationContext Maven / Gradle / Ivy

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);
	  }
	}
      });
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy