Package org.nuxeo.runtime.test.runner
Class FeaturesRunner
java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
org.nuxeo.runtime.test.runner.FeaturesRunner
- All Implemented Interfaces:
org.junit.runner.Describable,org.junit.runner.manipulation.Filterable,org.junit.runner.manipulation.Orderable,org.junit.runner.manipulation.Sortable
public class FeaturesRunner
extends org.junit.runners.BlockJUnit4ClassRunner
A Test Case runner that can be extended through features and provide injection though Guice.
- Author:
- Bogdan Stefanescu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected classprotected classprotected classprotected classprotected classprotected static enumprotected static classprotected classFeaturesRunner.RulesFactory<A extends Annotation,R> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.google.inject.InjectorGuice injector.protected final org.nuxeo.runtime.test.runner.FeaturesLoaderprotected final TargetResourceLocatorprotected static final AnnotationScannerprotected Object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterMethodRun(org.junit.runners.model.FrameworkMethod method, Object test) protected voidafterRun()protected voidafterTeardown(org.junit.runners.model.FrameworkMethod method, Object test) protected voidapply(String id, Collection<org.nuxeo.runtime.test.runner.FeaturesLoader.Holder> holders, ThrowableConsumer<org.nuxeo.runtime.test.runner.FeaturesLoader.Holder, Exception> consumer) protected voidapply(String id, FeaturesRunner.Direction direction, ThrowableConsumer<org.nuxeo.runtime.test.runner.FeaturesLoader.Holder, Exception> consumer) protected voidbeforeMethodRun(org.junit.runners.model.FrameworkMethod method, Object test) protected voidprotected voidbeforeSetup(org.junit.runners.model.FrameworkMethod method, Object test) protected org.junit.runners.model.StatementclassBlock(org.junit.runner.notification.RunNotifier aNotifier) protected List<org.junit.rules.TestRule> protected List<org.junit.runners.model.FrameworkMethod> voidevaluateRunnable(ThrowableRunnable<Throwable> runnable, ThrowableRunnable<Throwable> finisher) protected StringformatFeatures(Collection<org.nuxeo.runtime.test.runner.FeaturesLoader.Holder> holders) <T extends Annotation>
List<T> getAnnotations(Class<T> type) Returns the list of annotations present on the test class, then on the interfaces implemented by the test class, then on its super class, then on the different features.<T extends Annotation>
List<T> getAnnotations(Class<T> type, org.junit.runners.model.FrameworkMethod method) Returns the list of annotations for the given method.static StringDeprecated, for removal: This API element is subject to removal in a future version.<T extends Annotation>
T<T extends Annotation>
TGet the annotation on the test method, if no annotation has been found, get the annotation from the test class (SeegetConfig(Class))<T extends RunnerFeature>
TgetFeature(Class<T> aType) com.google.inject.Injector<T extends Annotation>
List<T> getMethodAnnotationsWithClassFallback(Class<T> type, org.junit.runners.model.FrameworkMethod method) Returns the list of annotations for the given method, if no annotation has been found, get the annotations for the current test.<T extends Annotation>
List<T> getMethodOrTestAnnotations(Class<T> type, org.junit.runners.model.FrameworkMethod method) Returns the list of annotations for the given method if the method is given, otherwise return the list of annotations for the current test.static AnnotationScannerDeprecated.since 11.1, seems unusedClass<?> May return null if the test class was not yet instantiatedgetTargetTestResource(String name) protected List<org.junit.rules.TestRule> getTestRules(Object target) protected voidprotected com.google.inject.InjectoronInjector(org.junit.runner.notification.RunNotifier aNotifier) protected List<org.junit.rules.MethodRule> protected voidstart()protected voidstop()protected voidthrowSeriousError(Throwable cause) toString()protected voidvalidateZeroArgConstructor(List<Throwable> errors) protected org.junit.runners.model.StatementwithAfterClasses(org.junit.runners.model.Statement statement) protected org.junit.runners.model.StatementwithAfters(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement) protected org.junit.runners.model.StatementwithBefores(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement) Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, createTest, describeChild, getChildren, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, runChild, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, withPotentialTimeoutMethods inherited from class org.junit.runners.ParentRunner
childrenInvoker, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withBeforeClasses, withInterruptIsolationMethods inherited from class org.junit.runner.Runner
testCount
-
Field Details
-
scanner
-
injector
protected com.google.inject.Injector injectorGuice injector. -
loader
protected final org.nuxeo.runtime.test.runner.FeaturesLoader loader -
locator
-
underTest
-
-
Constructor Details
-
FeaturesRunner
- Throws:
org.junit.runners.model.InitializationError
-
-
Method Details
-
getScanner
-
getBuildDirectory
Deprecated, for removal: This API element is subject to removal in a future version.Returns the Maven build directory, depending on thecustom.environmentsystem property.- Since:
- 11.1
-
getTargetTestClass
-
getTargetTestInstance
May return null if the test class was not yet instantiated -
getTargetTestBasepath
Deprecated.since 11.1, seems unused -
getTargetTestResource
- Throws:
IOException
-
getFeatures
-
getAnnotations
Returns the list of annotations present on the test class, then on the interfaces implemented by the test class, then on its super class, then on the different features.- Returns:
- the list of annotations for the current test
- Since:
- 2021.15
-
getAnnotations
public <T extends Annotation> List<T> getAnnotations(Class<T> type, org.junit.runners.model.FrameworkMethod method) Returns the list of annotations for the given method.- Returns:
- the list of annotations for the given method
- Since:
- 2021.15
-
getMethodOrTestAnnotations
public <T extends Annotation> List<T> getMethodOrTestAnnotations(Class<T> type, @Nullable org.junit.runners.model.FrameworkMethod method) Returns the list of annotations for the given method if the method is given, otherwise return the list of annotations for the current test.This is a convenient method for feature that has the same code to execute for before class and before method steps.
- Returns:
- the list of annotations for the given method
- Since:
- 2021.15
-
getMethodAnnotationsWithClassFallback
public <T extends Annotation> List<T> getMethodAnnotationsWithClassFallback(Class<T> type, @Nullable org.junit.runners.model.FrameworkMethod method) Returns the list of annotations for the given method, if no annotation has been found, get the annotations for the current test.- Returns:
- the list of annotations for the given method, if they exist, otherwise the list of annotations for the current test
- Since:
- 2021.15
-
getConfig
- Since:
- 5.6
-
getConfig
public <T extends Annotation> T getConfig(org.junit.runners.model.FrameworkMethod method, Class<T> type) Get the annotation on the test method, if no annotation has been found, get the annotation from the test class (SeegetConfig(Class))- Since:
- 5.7
-
computeTestMethods
- Overrides:
computeTestMethodsin classorg.junit.runners.BlockJUnit4ClassRunner
-
initialize
- Throws:
Exception
-
beforeRun
protected void beforeRun() -
beforeMethodRun
-
afterMethodRun
-
afterRun
protected void afterRun() -
start
protected void start() -
stop
protected void stop() -
beforeSetup
-
afterTeardown
-
apply
protected void apply(String id, FeaturesRunner.Direction direction, ThrowableConsumer<org.nuxeo.runtime.test.runner.FeaturesLoader.Holder, Exception> consumer) - Since:
- 11.1
-
apply
protected void apply(String id, Collection<org.nuxeo.runtime.test.runner.FeaturesLoader.Holder> holders, ThrowableConsumer<org.nuxeo.runtime.test.runner.FeaturesLoader.Holder, Exception> consumer) - Since:
- 11.1
-
formatFeatures
protected String formatFeatures(Collection<org.nuxeo.runtime.test.runner.FeaturesLoader.Holder> holders) -
evaluateRunnable
public void evaluateRunnable(ThrowableRunnable<Throwable> runnable, ThrowableRunnable<Throwable> finisher) throws Throwable - Throws:
Throwable
-
throwSeriousError
-
getInjector
public com.google.inject.Injector getInjector() -
onInjector
protected com.google.inject.Injector onInjector(org.junit.runner.notification.RunNotifier aNotifier) -
withAfterClasses
protected org.junit.runners.model.Statement withAfterClasses(org.junit.runners.model.Statement statement) - Overrides:
withAfterClassesin classorg.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
classBlock
protected org.junit.runners.model.Statement classBlock(org.junit.runner.notification.RunNotifier aNotifier) - Overrides:
classBlockin classorg.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
classRules
- Overrides:
classRulesin classorg.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
withBefores
protected org.junit.runners.model.Statement withBefores(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement) - Overrides:
withBeforesin classorg.junit.runners.BlockJUnit4ClassRunner
-
withAfters
protected org.junit.runners.model.Statement withAfters(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement) - Overrides:
withAftersin classorg.junit.runners.BlockJUnit4ClassRunner
-
getTestRules
- Overrides:
getTestRulesin classorg.junit.runners.BlockJUnit4ClassRunner
-
rules
- Overrides:
rulesin classorg.junit.runners.BlockJUnit4ClassRunner
-
createTest
- Overrides:
createTestin classorg.junit.runners.BlockJUnit4ClassRunner- Throws:
Exception
-
validateZeroArgConstructor
- Overrides:
validateZeroArgConstructorin classorg.junit.runners.BlockJUnit4ClassRunner
-
toString
-
getFeature
-