Share via


SyncAsyncExtension Class

  • java.lang.Object
    • com.azure.core.test.SyncAsyncExtension

Implements

org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider

public final class SyncAsyncExtension
implements org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider

A test template extension that helps to branch out a single test into sync and async invocation.

Constructor Summary

Constructor Description
SyncAsyncExtension()

Creates a new instance of SyncAsyncExtension.

Method Summary

Modifier and Type Method and Description
static T execute(Callable<T> sync, Callable<Mono<T>> async)

Executes sync or async branch depending on the context.

static void execute(Runnable sync, Callable<Mono<Void>> async)

Executes sync or async branch depending on the context.

Stream<org.junit.jupiter.api.extension.TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext extensionContext)
boolean supportsTestTemplate(ExtensionContext extensionContext)

Methods inherited from java.lang.Object

Constructor Details

SyncAsyncExtension

public SyncAsyncExtension()

Creates a new instance of SyncAsyncExtension.

Method Details

execute

public static T <T>execute(Callable<T> sync, Callable<Mono<T>> async)

Executes sync or async branch depending on the context.

Parameters:

sync - sync callable.
async - async callable. It should block at some point to return result.

Returns:

result of either sync or async invocation.

execute

public static void execute(Runnable sync, Callable<Mono<Void>> async)

Executes sync or async branch depending on the context.

Parameters:

sync - sync callable.
async - async callable. It should block at some point to return result.

provideTestTemplateInvocationContexts

public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext extensionContext)

Parameters:

extensionContext

supportsTestTemplate

public boolean supportsTestTemplate(ExtensionContext extensionContext)

Parameters:

extensionContext

Applies to