Package com.peterphi.std.guice.testing
Class GuiceUnit
java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
com.peterphi.std.guice.testing.GuiceUnit
- All Implemented Interfaces:
org.junit.runner.Describable,org.junit.runner.manipulation.Filterable,org.junit.runner.manipulation.Orderable,org.junit.runner.manipulation.Sortable
public class GuiceUnit
extends org.junit.runners.BlockJUnit4ClassRunner
A JUnit runner for the guice framework; test classes are generally annotated with
GuiceConfig to indicate the desired guice
environment customisation.
This implementation is based on Jukito's JukitoRunner-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.junit.runners.model.FrameworkMethod>protected Objectprotected org.junit.runners.model.StatementmethodBlock(org.junit.runners.model.FrameworkMethod method) protected org.junit.runners.model.StatementmethodInvoker(org.junit.runners.model.FrameworkMethod method, Object test) voidrun(org.junit.runner.notification.RunNotifier notifier) protected StringtestName(org.junit.runners.model.FrameworkMethod method) protected voidvalidateInstanceMethods(List<Throwable> errors) Deprecated.protected voidvalidatePublicVoidMethods(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors) Adds toerrorsif any method in this class is annotated with the providedannotation, but: is not public, or returns something other than void, or is static (givenisStatic is false), or is not static (givenisStatic is true).protected voidvalidateTestMethods(List<Throwable> errors) Adds toerrorsfor each method annotated with@Testthat is not a public, void instance method.protected org.junit.runners.model.StatementwithAfters(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement) Deprecated.deprecated inBlockJUnit4ClassRunnerand going away in a future version.protected org.junit.runners.model.StatementwithBefores(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement) Deprecated.deprecated inBlockJUnit4ClassRunnerand going away in a future version.Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, createTest, describeChild, getChildren, getTestRules, isIgnored, possiblyExpectingExceptions, rules, runChild, validateConstructor, validateFields, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateZeroArgConstructor, withPotentialTimeoutMethods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolationMethods inherited from class org.junit.runner.Runner
testCount
-
Constructor Details
-
GuiceUnit
Creates a BlockJUnit4ClassRunner to runclazz- Parameters:
clazz-- Throws:
org.junit.runners.model.InitializationError- if the test class is malformed.
-
-
Method Details
-
createTest
- Overrides:
createTestin classorg.junit.runners.BlockJUnit4ClassRunner- Throws:
Exception
-
methodBlock
protected org.junit.runners.model.Statement methodBlock(org.junit.runners.model.FrameworkMethod method) - Overrides:
methodBlockin classorg.junit.runners.BlockJUnit4ClassRunner
-
run
public void run(org.junit.runner.notification.RunNotifier notifier) - Overrides:
runin classorg.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
methodInvoker
protected org.junit.runners.model.Statement methodInvoker(org.junit.runners.model.FrameworkMethod method, Object test) - Overrides:
methodInvokerin classorg.junit.runners.BlockJUnit4ClassRunner
-
withBefores
protected org.junit.runners.model.Statement withBefores(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement) Deprecated.deprecated inBlockJUnit4ClassRunnerand going away in a future version. Should be changed to use Rules.Wrap a statement with logic that must run before it executes- Overrides:
withBeforesin classorg.junit.runners.BlockJUnit4ClassRunner- Parameters:
method-target-statement-- Returns:
-
withAfters
protected org.junit.runners.model.Statement withAfters(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement) Deprecated.deprecated inBlockJUnit4ClassRunnerand going away in a future version. Should be changed to use Rules.Wrap a statement with logic that must run after it executes- Overrides:
withAftersin classorg.junit.runners.BlockJUnit4ClassRunner- Parameters:
method-target-statement-- Returns:
-
testName
- Overrides:
testNamein classorg.junit.runners.BlockJUnit4ClassRunner
-
computeTestMethods
- Overrides:
computeTestMethodsin classorg.junit.runners.BlockJUnit4ClassRunner
-
validateInstanceMethods
Deprecated.deprecated inBlockJUnit4ClassRunnerand going away in a future versionAdds toerrorsfor each method annotated with@Test,@Before, or@Afterthat is not a public, void instance method with no arguments.- Overrides:
validateInstanceMethodsin classorg.junit.runners.BlockJUnit4ClassRunner
-
validateTestMethods
Adds toerrorsfor each method annotated with@Testthat is not a public, void instance method. Note: it is permitted to have arguments (superclass requires that methods have no arguments)- Overrides:
validateTestMethodsin classorg.junit.runners.BlockJUnit4ClassRunner
-
validatePublicVoidMethods
protected void validatePublicVoidMethods(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors) Adds toerrorsif any method in this class is annotated with the providedannotation, but:- is not public, or
- returns something other than void, or
- is static (given
isStatic is false), or - is not static (given
isStatic is true).
- See Also:
-
validatePublicVoidNoArgMethods for a no-arg version of this validation
-
BlockJUnit4ClassRunnerand going away in a future version