public class UnitTestServer
extends java.lang.Object
UnitTestEngine interface.| Modifier and Type | Class and Description |
|---|---|
private static class |
UnitTestServer.WorkArea
Context local work area.
|
| Modifier and Type | Field and Description |
|---|---|
private static ContextLocal<UnitTestServer.WorkArea> |
context
Context local work area.
|
private static java.util.function.Predicate<java.lang.Class<?>> |
isTestClassCandidate
Filter only class types which can contain tests or are test providers:
public non-abstract non-internal.
|
private static java.util.regex.Pattern |
legacyErrorStackTraceElementRegexp
Legacy stack trace entry pattern
|
(package private) static CentralLogger |
LOG
Logger for this test engine
|
| Constructor and Description |
|---|
UnitTestServer() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
addOptionally(org.junit.platform.engine.TestDescriptor parentDescriptor,
java.lang.Class<?> javaClass,
java.lang.reflect.Method explicitMethods)
Scan a class for test methods, declared in the class.
|
static void |
after(org.junit.platform.engine.UniqueId testId)
Execute the after behavior of this node.
|
static void |
before(org.junit.platform.engine.UniqueId testId)
Execute the before behavior of this node.
|
static void |
cleanUp(org.junit.platform.engine.UniqueId testId)
Clean up the supplied
context after execution. |
private static java.util.List<java.lang.reflect.Method> |
collectAnnotatedMethods(java.lang.Class<?> clazz,
java.lang.Class<? extends java.lang.annotation.Annotation> annoClass,
boolean topDown)
Collect all methods annotated with the given class, but not annotated as disabled.
|
private static void |
convertError(java.lang.Runnable action)
Run the provided code, convert legacy errors thrown to
AbstractAssertionFailedError
and throw the result. |
protected static void |
convertError(java.lang.Runnable action,
java.lang.String expectedExceptionClassName)
Run the provided code, convert legacy errors thrown into
AbstractAssertionFailedError
along with legacy error stack trace, throw the result. |
static org.junit.platform.engine.TestDescriptor |
discover(org.junit.platform.engine.UniqueId uniqueId,
java.net.URI[] classroots,
java.lang.String[] packages,
java.lang.String[] classes,
java.lang.String[] methods,
java.net.URI[] uris,
java.lang.String[] files,
java.lang.String[] directories,
java.lang.String[] modules,
java.lang.String[] resources,
java.lang.String[] iterations)
Discover test sources provided as arguments.
|
static void |
execute(org.junit.platform.engine.UniqueId testId)
Execute the behavior of this node.
|
private static AbstractFWDTestDescriptor |
getDescriptor(org.junit.platform.engine.UniqueId testId)
Find descriptor by its ID.
|
static void |
initialize()
Initialize FWD server.
|
private static boolean |
methodIsAnnotatedAndPublic(java.lang.reflect.Method method,
java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
Test if a method is annotated with the given annotation,
and is not annotated with the
Disabled annotation,
and is public. |
static void |
prepare(org.junit.platform.engine.UniqueId testId)
Prepare test descriptor.
|
private static void |
register(AbstractFWDTestDescriptor descriptor)
Register a new descriptor.
|
private static void |
scanClassRecursively(org.junit.platform.engine.TestDescriptor engineDescriptor,
java.lang.Class<?> javaClass)
Recursively scan a class for all test methods, including whose defined in the class
and referenced classes, if the class is marked as test suite.
|
private static AbstractClassTestDescriptor |
testAndCreate(java.lang.Class<?> clazz,
org.junit.platform.engine.TestDescriptor parentDescriptor,
java.lang.reflect.Method optionalMethod)
Test a Java class candidate for existent tests methods.
|
static final CentralLogger LOG
private static final ContextLocal<UnitTestServer.WorkArea> context
private static final java.util.function.Predicate<java.lang.Class<?>> isTestClassCandidate
private static final java.util.regex.Pattern legacyErrorStackTraceElementRegexp
public static void after(org.junit.platform.engine.UniqueId testId)
throws ErrorConditionException,
org.opentest4j.AssertionFailedError
This method will be called once after execution of this node.
testId - test descriptor IDErrorConditionException - remote code may throw thisorg.opentest4j.AssertionFailedError - remote legacy errors are converted to this
exception typepublic static void before(org.junit.platform.engine.UniqueId testId)
throws ErrorConditionException,
org.opentest4j.AssertionFailedError
This method will be called once before execution of this node.
testId - test descriptor IDErrorConditionException - remote code may throw thisorg.opentest4j.AssertionFailedError - remote legacy errors are converted to this
exception typepublic static void cleanUp(org.junit.platform.engine.UniqueId testId)
context after execution.
Reset the test class instance.
testId - test descriptor IDprepare(org.junit.platform.engine.UniqueId)public static org.junit.platform.engine.TestDescriptor discover(org.junit.platform.engine.UniqueId uniqueId,
java.net.URI[] classroots,
java.lang.String[] packages,
java.lang.String[] classes,
java.lang.String[] methods,
java.net.URI[] uris,
java.lang.String[] files,
java.lang.String[] directories,
java.lang.String[] modules,
java.lang.String[] resources,
java.lang.String[] iterations)
throws ErrorConditionException,
org.opentest4j.AssertionFailedError
Note: only the classroots, packages, classes, methods and modules are supported by this engine. All other parameters can have no relation neither to ABLUnit nor OEUnit, and are preserved for possible future extensions.
uniqueId - the engine unique IDclassroots - the list of class root URLspackages - the list of packagesclasses - the list of class namesmethods - the list of method specificationsuris - the list of URIsfiles - the list of filesdirectories - the list of directoriesmodules - the list of modulesresources - the list of resourcesiterations - the list of iterations (currently not supported)null if no match was found.ErrorConditionException - remote code may throw thisorg.opentest4j.AssertionFailedError - remote legacy errors are converted to this
exception typepublic static void execute(org.junit.platform.engine.UniqueId testId)
throws ErrorConditionException,
org.opentest4j.AssertionFailedError
Locate the test descriptor by its unique ID and calls
AbstractFWDTestDescriptor.executeImpl()
testId - test descriptor IDErrorConditionException - remote code may throw thisorg.opentest4j.AssertionFailedError - remote legacy errors are converted to this
exception typepublic static void initialize()
public static void prepare(org.junit.platform.engine.UniqueId testId)
throws ErrorConditionException,
org.opentest4j.AssertionFailedError
Locate the test descriptor by its unique ID and calls
AbstractFWDTestDescriptor.prepareImpl()
testId - test descriptor IDErrorConditionException - remote code may throw thisorg.opentest4j.AssertionFailedError - remote legacy errors are converted to this
exception typeprotected static final void convertError(java.lang.Runnable action,
java.lang.String expectedExceptionClassName)
throws ErrorConditionException,
org.opentest4j.AssertionFailedError
AbstractAssertionFailedError
along with legacy error stack trace, throw the result.
This is a FWD extension to support test runners (e.g. Eclipse), which "know" how to display
AssertionFailedError specially.
action - the action to run, must return the legacy error thrown or nullexpectedExceptionClassName - the expected legacy error class name or an empty string if no legacy error was expectedErrorConditionException - remote code may throw thisorg.opentest4j.AssertionFailedError - remote legacy errors are converted to this
exception typeprivate static final void addOptionally(org.junit.platform.engine.TestDescriptor parentDescriptor,
java.lang.Class<?> javaClass,
java.lang.reflect.Method explicitMethods)
parentDescriptor - the parent descriptor to register found test descriptors injavaClass - the Java class to scanexplicitMethods - optional list of explicit test methods to execute, can be nullprivate static final boolean methodIsAnnotatedAndPublic(java.lang.reflect.Method method,
java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
Disabled annotation,
and is public.
Log methods, which are properly annotated, but are not public.method - the method to testannoClass - the annotation to testtrue is the method argument matches the criteriaprivate static final java.util.List<java.lang.reflect.Method> collectAnnotatedMethods(java.lang.Class<?> clazz,
java.lang.Class<? extends java.lang.annotation.Annotation> annoClass,
boolean topDown)
clazz - the class to scan for methodsannoClass - the annotation class to matchtopDown - if true, then traverse class hierarchy top-down, otherwise traverse bottom-up.nullprivate static final void convertError(java.lang.Runnable action)
throws ErrorConditionException,
org.opentest4j.AssertionFailedError
AbstractAssertionFailedError
and throw the result.
This is a FWD extension to support test runners (e.g. Eclipse), which "knows" how to display
AbstractAssertionFailedError specially.
action - the action to run, must return the legacy error thrown or nullErrorConditionException - remote code may throw thisorg.opentest4j.AssertionFailedError - remote legacy errors are converted to this
exception typeprivate static final AbstractFWDTestDescriptor getDescriptor(org.junit.platform.engine.UniqueId testId)
testId - unique IDprivate static final void register(AbstractFWDTestDescriptor descriptor)
descriptor - the descriptor to registerprivate static final void scanClassRecursively(org.junit.platform.engine.TestDescriptor engineDescriptor,
java.lang.Class<?> javaClass)
throws ErrorConditionException,
org.opentest4j.AssertionFailedError
engineDescriptor - the engine descriptor to register found test descriptors injavaClass - the Java class to scanErrorConditionException - remote code may throw thisorg.opentest4j.AssertionFailedError - remote legacy errors are converted to this
exception typeprivate static final AbstractClassTestDescriptor testAndCreate(java.lang.Class<?> clazz, org.junit.platform.engine.TestDescriptor parentDescriptor, java.lang.reflect.Method optionalMethod)
clazz - the class under testparentDescriptor - the parent descriptoroptionalMethod - the explicit method or null to scan the class for all test methodsnull if this class has no test methods.