Class TeaVMJupiterExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.ExecutionCondition,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.InvocationInterceptor
@Test-annotated methods on every enabled TeaVM backend (JS, Wasm GC, C), in addition
to the plain JVM.
By default, all test methods of a class are compiled together into one artifact per backend
(in beforeAll(org.junit.jupiter.api.extension.ExtensionContext)), the same way TeaVMTestRunner does for JUnit 4/TestNG — compiling
once per class is far cheaper than compiling once per method. Annotate the class with
EachTestCompiledSeparately to opt out and compile each method on its own instead.
This only supports the subset of JUnit 5 that maps onto TeaVM's ahead-of-time compilation
model: plain @Test methods, @ParameterizedTest methods, instance-level
@BeforeEach/@AfterEach (recognized directly off the compiled class by
TestEntryPointTransformer, the same way JUnit 4's @Before/@After already
are), and TeaVM's own annotations (SkipPlatform, OnlyPlatform, SkipJVM,
JsModuleTest, TeaVMProperties). There's no support for the general
@ExtendWith extension mechanism, @Nested classes, dynamic tests, or
@BeforeAll/@AfterAll — none of those have a sound ahead-of-time-compiled
equivalent (or, in the case of other extensions, would require re-executing arbitrary reflective
JVM code inside the compiled artifact).
Arguments of parameterized tests are produced inside the compiled artifact (see
JupiterArgumentsPlan). All invocations run at once, within a single run of the compiled
test, when Jupiter performs the first invocation on the JVM; each invocation then reports the
result of the invocation with the same index (see InvocationResults). Supported argument sources are
@ValueSource, @CsvSource, @EnumSource, @NullSource,
@EmptySource, @NullAndEmptySource, @MethodSource and
@FieldSource (with parameterless factory methods). Explicit argument converters,
aggregators, @CsvFileSource and custom @ArgumentsSource providers are not
supported.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) org.junit.jupiter.api.extension.ConditionEvaluationResultevaluateExecutionCondition(org.junit.jupiter.api.extension.ExtensionContext context) voidinterceptAfterEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidinterceptBeforeEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidinterceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidinterceptTestTemplateMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
interceptAfterAllMethod, interceptBeforeAllMethod, interceptDynamicTest, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod
-
Constructor Details
-
TeaVMJupiterExtension
public TeaVMJupiterExtension()
-
-
Method Details
-
evaluateExecutionCondition
public org.junit.jupiter.api.extension.ConditionEvaluationResult evaluateExecutionCondition(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
evaluateExecutionConditionin interfaceorg.junit.jupiter.api.extension.ExecutionCondition
-
beforeAll
- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
interceptTestMethod
public void interceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptTestMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptBeforeEachMethod
public void interceptBeforeEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptBeforeEachMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptAfterEachMethod
public void interceptAfterEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptAfterEachMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptTestTemplateMethod
public void interceptTestTemplateMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptTestTemplateMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-