RestateTest

@ExtendWith(value = RestateExtension::class)
@TestInstance(value = TestInstance.Lifecycle.PER_CLASS)
annotation class RestateTest

Annotation to enable the Restate extension for JUnit 5. The annotation will bootstrap a Restate environment using TestContainers, and will automatically register all services field of the class annotated with BindService.

Example:

// Annotate the class as RestateTest to start a Restate environment
@RestateTest
class CounterTest { // Annotate the service to bind
@BindService
private final Counter counter = new Counter(); // Inject the client to send requests
@Test
void testGreet(
@RestateClient
Client ingressClient) { var client = CounterClient.fromClient(ingressClient, "my-counter"); long response = client.get(); assertThat(response).isEqualTo(0L); } }

The runner will deploy the services locally, execute Restate as container using Testcontainers, and register the services.

This extension is scoped per test class, meaning that the restate runner will be shared among test methods. Because of this behaviour, the extension sets the TestInstance as PER_CLASS automatically.

Use the annotations RestateClient, RestateURL and RestateAdminClient to interact with the deployed environment:

@Test
void initialCountIsZero(
@RestateClient
Client client) { var client = CounterClient.fromClient(ingressClient, "my-counter"); // Use client as usual long response = client.get(); assertThat(response).isEqualTo(0L); }

Functions

Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
Link copied to clipboard
abstract fun containerImage(): String
Restate container image to use
Link copied to clipboard
abstract fun environment(): Array<String>
Environment variables in form key=value that should be added to the deployed Restate container.
Link copied to clipboard
abstract fun equals(p: Any): Boolean
Link copied to clipboard
abstract fun hashCode(): Int
Link copied to clipboard
abstract fun toString(): String