
de.bechte.junit.runners.context.statements.StatementExecutorFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-hierarchicalcontextrunner Show documentation
Show all versions of junit-hierarchicalcontextrunner Show documentation
This is a runner implementation that supports context hierarchies in JUnit. For more
details please visit: https://github.com/bechte/junit-hierarchicalcontextrunner/wiki
package de.bechte.junit.runners.context.statements;
/**
* The {@link StatementExecutorFactory} resolves the {@link StatementExecutor}s for classes and methods. These two
* types might differ, as they require different reporting.
*
* Note: Clients can register their own factory by setting the system property with key {@code PROPERTY_KEY}. This
* property must contain a name of the implementation class, e.g. "com.you.factories.MyStatementExecutorFactory".
* If no property is set the {@link DefaultStatementExecutorFactory} will be used instead.
*/
public abstract class StatementExecutorFactory {
protected static final String PROPERTY_KEY = StatementExecutorFactory.class.getCanonicalName();
private static StatementExecutorFactory factory = null;
public static StatementExecutorFactory getDefault() {
if (factory == null)
lazyLoadFactory();
return factory;
}
private static void lazyLoadFactory() {
final String factoryName = System.getProperty(PROPERTY_KEY);
try {
factory = (factoryName == null)
? new DefaultStatementExecutorFactory()
: (StatementExecutorFactory) Class.forName(factoryName).newInstance();
} catch (final Throwable t) {
throw new IllegalStateException("JUnit system not configured correctly. " +
"Cannot find StatementExecutorFactory! Invalid factory name given: " + factoryName, t);
}
}
protected StatementExecutorFactory() {
super();
}
public abstract StatementExecutor getExecutorForClasses();
public abstract StatementExecutor getExecutorForMethods();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy