package testkit
- Alphabetic
- Public
- Protected
Type Members
- class ActorSystemExtension extends BeforeEachCallback with AfterEachCallback
A JUnit 5 (Jupiter) Extension that manages the lifecycle of an ActorSystem.
A JUnit 5 (Jupiter) Extension that manages the lifecycle of an ActorSystem.
This is the JUnit 5 counterpart of ActorSystemResource which uses JUnit 4's org.junit.rules.ExternalResource. It implements BeforeEachCallback and AfterEachCallback to create and terminate the ActorSystem around each test method.
Usage with
@RegisterExtension:@RegisterExtension ActorSystemExtension systemExtension = new ActorSystemExtension("MyTest", ConfigFactory.empty());
Or use it indirectly through JUnitJupiterRouteTest.
- final case class DefaultHostInfo(host: Host, securedConnection: Boolean) extends Product with Serializable
- abstract class JUnitJupiterRouteTest extends JUnitJupiterRouteTestBase
JUnit Jupiter route test base class.
JUnit Jupiter route test base class. Extend this class to write HTTP route tests using JUnit Jupiter annotations (
@Test,@BeforeEach,@AfterEach, etc.).The ActorSystem is managed automatically via ActorSystemExtension. Override
additionalConfigto provide custom configuration.Example usage:
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; public class MyRouteTest extends JUnitJupiterRouteTest { @Test public void testHello() { testRoute(get(() -> complete("hello"))) .run(HttpRequest.GET("/")) .assertStatusCode(StatusCodes.OK); } }
- abstract class JUnitJupiterRouteTestBase extends RouteTest
A RouteTest that uses JUnit Jupiter assertions.
A RouteTest that uses JUnit Jupiter assertions. ActorSystem and Materializer lifecycle is managed via ActorSystemExtension, the JUnit Jupiter equivalent of org.junit.rules.ExternalResource.
This is the JUnit Jupiter counterpart of JUnitRouteTest. Migrate your tests from
extends JUnitRouteTesttoextends JUnitJupiterRouteTestto use JUnit Jupiter annotations and assertions. - abstract class RouteTest extends AllDirectives with WSTestRequestBuilding
A base class to create route tests for testing libraries.
A base class to create route tests for testing libraries. An implementation needs to provide code to provide and shutdown an pekko.actor.ActorSystem, pekko.stream.Materializer, and scala.concurrent.ExecutionContextExecutor.
See
JUnitRouteTestfor an example of a concrete implementation. - trait TestRoute extends AnyRef
A wrapped route that has a
runmethod to run a request through the underlying route to create a TestResponse.A wrapped route that has a
runmethod to run a request through the underlying route to create a TestResponse.A TestRoute is created by deriving a test class from the concrete RouteTest implementation for your testing framework (like JUnitRouteTest for JUnit) and then using its
testRoutemethod to wrap a route with testing support. - abstract class TestRouteResult extends AnyRef
A wrapper for route results.
A wrapper for route results.
To support the testkit API, a third-party testing library needs to implement this class and provide implementations for the abstract assertion methods.
- class WSProbe extends AnyRef
A WSProbe is a probe that implements a
Flow[Message, Message, Unit]for testing websocket code.A WSProbe is a probe that implements a
Flow[Message, Message, Unit]for testing websocket code.Requesting elements is handled automatically.
- trait WSTestRequestBuilding extends AnyRef
Deprecated Type Members
- class ActorSystemResource extends ExternalResource
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) Use ActorSystemExtension (Jupiter Junit support) instead
- abstract class JUnitRouteTest extends JUnitRouteTestBase
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) Use JUnitJupiterRouteTest instead
- abstract class JUnitRouteTestBase extends RouteTest
A RouteTest that uses JUnit assertions.
A RouteTest that uses JUnit assertions. ActorSystem and Materializer are provided as an org.junit.rules.ExternalResource and their lifetime is automatically managed.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) Use JUnitJupiterRouteTestBase instead