public class AnnotatedBuilder extends RunnerBuilder
AnnotatedBuilder
is a strategy for constructing runners for test class that have been annotated with the
@RunWith
annotation. All tests within this class will be executed using the runner that was specified within
the annotation.
If a runner supports inner member classes, the member classes will inherit the runner from the enclosing class, e.g.:
@RunWith(MyRunner.class) public class MyTest { // some tests might go here public class MyMemberClass { @Test public void thisTestRunsWith_MyRunner() { // some test logic } // some more tests might go here } @RunWith(AnotherRunner.class) public class AnotherMemberClass { // some tests might go here public class DeepInnerClass { @Test public void thisTestRunsWith_AnotherRunner() { // some test logic } } public class DeepInheritedClass extends SuperTest { @Test public void thisTestRunsWith_SuperRunner() { // some test logic } } } } @RunWith(SuperRunner.class) public class SuperTest { // some tests might go here }The key points to note here are:
RunnerBuilder
,
RunWith
Constructor and Description |
---|
AnnotatedBuilder(RunnerBuilder suiteBuilder) |
Modifier and Type | Method and Description |
---|---|
Runner |
buildRunner(Class<? extends Runner> runnerClass,
Class<?> testClass) |
Runner |
runnerForClass(Class<?> testClass)
Override to calculate the correct runner for a test class at runtime.
|
runners, runners, safeRunnerForClass
public AnnotatedBuilder(RunnerBuilder suiteBuilder)
public Runner runnerForClass(Class<?> testClass) throws Exception
RunnerBuilder
runnerForClass
in class RunnerBuilder
testClass
- class to be runException
Copyright © 2002–2020 JUnit. All rights reserved.