Package org.spincast.testing.junitrunner
Class SpincastJUnitRunner
java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
org.spincast.testing.junitrunner.SpincastJUnitRunner
- All Implemented Interfaces:
org.junit.runner.Describable,org.junit.runner.manipulation.Filterable,org.junit.runner.manipulation.Orderable,org.junit.runner.manipulation.Sortable
public class SpincastJUnitRunner
extends org.junit.runners.BlockJUnit4ClassRunner
Spincast JUnit Runner.
Only creates one instance of the test class for all its tests.
If the class implements BeforeAfterClassMethodsProvider, then
a beforeClass() and afterClass() methods will be
called.
You can use the ExpectingBeforeClassException annotation on the test
class to indicate that an exception is expected from the beforeClass()
method.
If you try to debug a test that only fails sometimes (those are the
worst!), you can use the @RepeatUntilFail annotation on the test or on
its test class. This allows you to run the test or the whole test class multiple times.
You can also use @RepeatUntilSuccess instead to repeat
the test class (or a single test) multiple time until it succeeds (or the maximum
number of tries is reached).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.junit.runners.model.StatementaddCustomErrorHandling(org.junit.runners.model.Statement baseStatement, org.junit.runners.model.FrameworkMethod method) protected voidaddTestFailureListener(org.junit.runner.notification.RunNotifier notifier) protected final List<org.junit.runners.model.FrameworkMethod>JUnit calls that method to create an instance of the test class for each individual test.protected org.junit.runners.model.StatementcustomizeStatement(org.junit.runners.model.Statement statement, org.junit.runners.model.FrameworkMethod method) protected IntegergeRepeatUntilFailureAnnotationLoopsNbr(RepeatUntilFailure repeatUntilFailureAnnotation) Will benullif there if noRepeatUntilFailureannotation.protected IntegergeRepeatUntilSuccessAnnotationLoopsNbr(RepeatUntilSuccess repeatUntilSuccessAnnotation) Will benullif there if noRepeatUntilSuccessannotation.protected intprotected IntegerWill benullif there if noRepeatUntilFailureannotation.protected IntegerWill benullif there if noRepeatUntilFailureannotation.protected IntegerWill benullif there if noRepeatUntilSuccessannotation.protected IntegerWill benullif there if noRepeatUntilSuccessannotation.protected StringgetName()Test class display name.protected IntegergetRepeatUntilFailureAnnotationLoopsSleep(RepeatUntilFailure repeatAnnotation) Will benullif there if noRepeatUntilFailureannotation.protected IntegergetRepeatUntilSuccessAnnotationLoopsSleep(RepeatUntilSuccess repeatUntilSuccessAnnotation) Will benullif there if noRepeatUntilSuccessannotation.protected org.junit.runner.notification.RunNotifierprotected Stringprotected Objectprotected IntegerWill benullif there if noRepeatUntilFailureannotation.protected IntegerWill benullif there if noRepeatUntilFailureannotation.protected IntegerWill benullif there if noRepeatUntilSuccessannotation.protected IntegerWill benullif there if noRepeatUntilSuccessannotation.protected booleanbooleanbooleanprotected booleanprotected booleanprotected voidlogTestFailure(org.junit.runner.notification.Failure failure) protected org.junit.runners.model.StatementmethodBlock(org.junit.runners.model.FrameworkMethod method) voidrun(org.junit.runner.notification.RunNotifier notifier) Runs the test class.protected voidrunChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier) Runs a specific testprotected voidprotected voidprotected voidprotected voidspincastTestError(String testName, String errorMessage) protected voidspincastTestError(String testName, Throwable exception) protected voidtestFailureCustomHandling(org.junit.runner.notification.Failure failure) protected voidprotected voidprotected voidprotected voidMethods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, createTest, describeChild, getChildren, getTestRules, isIgnored, methodInvoker, possiblyExpectingExceptions, rules, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeoutMethods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getRunnerAnnotations, getTestClass, order, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolationMethods inherited from class org.junit.runner.Runner
testCount
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
SPINCAST_TEST_NAME_BEFORE_CLASS_ANNOTATIONS_VALIDATION
-
SPINCAST_TEST_NAME_AFTER_CLASS_ANNOTATIONS_VALIDATION
-
SPINCAST_TEST_NAME_BEFORE_CLASS_METHOD_VALIDATION
- See Also:
-
SPINCAST_TEST_NAME_AFTER_CLASS_METHOD_VALIDATION
- See Also:
-
SPINCAST_TEST_NAME_NO_TESTS_AND_NO_EXPECTION_EXCEPTION_ANNOTATION
-
SPINCAST_TEST_NAME_AFTER_CLASS_LOOPS_EXCEPTION
- See Also:
-
SPINCAST_TEST_NAME_REPEAT_ANNOTATIONS_VALIDATION
-
SPINCAST_TEST_NAME_EXPECTING_FAILURE_BUT_ONLY_SUCCESSES
-
-
Constructor Details
-
SpincastJUnitRunner
- Throws:
org.junit.runners.model.InitializationError
-
-
Method Details
-
getRunNotifier
protected org.junit.runner.notification.RunNotifier getRunNotifier() -
setIgnoreRemainingTests
protected void setIgnoreRemainingTests() -
isIgnoreRemainingTests
protected boolean isIgnoreRemainingTests() -
setExceptionInBeforeClass
protected void setExceptionInBeforeClass() -
isExceptionInBeforeClass
protected boolean isExceptionInBeforeClass() -
getCurrentClassLoopPosition
protected int getCurrentClassLoopPosition() -
createTest
JUnit calls that method to create an instance of the test class for each individual test. We change this behavior and always return the *same* instance of the test class: 'testClassInstance'.- Overrides:
createTestin classorg.junit.runners.BlockJUnit4ClassRunner- Throws:
Exception
-
getTestClassInstance
-
getName
Test class display name.- Overrides:
getNamein classorg.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
computeTestMethods
- Overrides:
computeTestMethodsin classorg.junit.runners.BlockJUnit4ClassRunner
-
run
public void run(org.junit.runner.notification.RunNotifier notifier) Runs the test class.- Overrides:
runin classorg.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
runChild
protected void runChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier) Runs a specific test- Overrides:
runChildin classorg.junit.runners.BlockJUnit4ClassRunner
-
methodBlock
protected org.junit.runners.model.Statement methodBlock(org.junit.runners.model.FrameworkMethod method) - Overrides:
methodBlockin classorg.junit.runners.BlockJUnit4ClassRunner
-
customizeStatement
protected org.junit.runners.model.Statement customizeStatement(org.junit.runners.model.Statement statement, org.junit.runners.model.FrameworkMethod method) -
addCustomErrorHandling
protected org.junit.runners.model.Statement addCustomErrorHandling(org.junit.runners.model.Statement baseStatement, org.junit.runners.model.FrameworkMethod method) -
addTestFailureListener
protected void addTestFailureListener(org.junit.runner.notification.RunNotifier notifier) -
testFailureCustomHandling
protected void testFailureCustomHandling(org.junit.runner.notification.Failure failure) -
logTestFailure
protected void logTestFailure(org.junit.runner.notification.Failure failure) -
isLastInstanceOfThisTestToRun
protected boolean isLastInstanceOfThisTestToRun() -
runPreClassLoopsSpincastTests
protected void runPreClassLoopsSpincastTests() -
validateNoBeforeClassAnnotations
protected void validateNoBeforeClassAnnotations() -
validateNoAfterClassAnnotations
protected void validateNoAfterClassAnnotations() -
validateNoTestsAndNoExpectingBeforeClassExceptionAnnotation
protected void validateNoTestsAndNoExpectingBeforeClassExceptionAnnotation() -
validateTestClassRepeateAnnotations
protected void validateTestClassRepeateAnnotations() -
spincastTestError
-
spincastTestError
-
getStackTrace
-
isExpectingBeforeClassException
public boolean isExpectingBeforeClassException() -
isExpectingFailure
public boolean isExpectingFailure() -
getTestClassRepeatUntilFailureAnnotationLoopsNbr
Will benullif there if noRepeatUntilFailureannotation. -
getMethodRepeatUntilFailureAnnotationLoopsNbr
Will benullif there if noRepeatUntilFailureannotation. -
geRepeatUntilFailureAnnotationLoopsNbr
protected Integer geRepeatUntilFailureAnnotationLoopsNbr(RepeatUntilFailure repeatUntilFailureAnnotation) Will benullif there if noRepeatUntilFailureannotation. -
getTestClassRepeatUntilFailureAnnotationLoopsSleep
Will benullif there if noRepeatUntilFailureannotation. -
getMethodRepeatUntilFailureAnnotationLoopsSleep
Will benullif there if noRepeatUntilFailureannotation. -
getRepeatUntilFailureAnnotationLoopsSleep
Will benullif there if noRepeatUntilFailureannotation. -
getTestClassRepeatUntilSuccessAnnotationLoopsNbr
Will benullif there if noRepeatUntilSuccessannotation. -
getMethodRepeatUntilSuccessAnnotationLoopsNbr
Will benullif there if noRepeatUntilSuccessannotation. -
geRepeatUntilSuccessAnnotationLoopsNbr
protected Integer geRepeatUntilSuccessAnnotationLoopsNbr(RepeatUntilSuccess repeatUntilSuccessAnnotation) Will benullif there if noRepeatUntilSuccessannotation. -
getTestClassRepeatUntilSuccessAnnotationLoopsSleep
Will benullif there if noRepeatUntilSuccessannotation. -
getMethodRepeatUntilSuccessAnnotationLoopsSleep
Will benullif there if noRepeatUntilSuccessannotation. -
getRepeatUntilSuccessAnnotationLoopsSleep
protected Integer getRepeatUntilSuccessAnnotationLoopsSleep(RepeatUntilSuccess repeatUntilSuccessAnnotation) Will benullif there if noRepeatUntilSuccessannotation.
-