The Java SDK comes with the module sdk-testing that integrates with JUnit 5 and Testcontainers to start up a Restate container together with your services code and automatically register them. Add the following dependency to your project: .

Using the JUnit 5 Extension

Given the service to test MyService, annotate the test class with @RestateTest and annotate the services to bind with @BindService:
@RestateTest
class MyServiceTest {

  @BindService MyService service = new MyService();

  // Your tests

}
Note that the extension will start one Restate server for the whole test class. For more details, checkout RestateTest Javadocs. Once the extension is set, you can implement your test methods as usual, and inject a Client using @RestateClient to interact with Restate and the registered services:
@Test
void testMyHandler(@RestateClient Client ingressClient) {
  // Create the service client from the injected ingress client
  var client = MyServiceClient.fromClient(ingressClient);

  // Send request to service and assert the response
  var response = client.myHandler("Hi");
  assertEquals(response, "Hi!");
}

Usage without JUnit 5

You can use the testing tools without JUnit 5 by using RestateRunner directly. For more details, refer to the Javadocs.