Packages

package testkit

Content Hierarchy
Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Type Members

  1. 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.

  2. final case class DefaultHostInfo(host: Host, securedConnection: Boolean) extends Product with Serializable
  3. 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 additionalConfig to 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);
        }
    }
  4. 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 JUnitRouteTest to extends JUnitJupiterRouteTest to use JUnit Jupiter annotations and assertions.

  5. 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 JUnitRouteTest for an example of a concrete implementation.

  6. trait TestRoute extends AnyRef

    A wrapped route that has a run method to run a request through the underlying route to create a TestResponse.

    A wrapped route that has a run method 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 testRoute method to wrap a route with testing support.

  7. 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.

  8. 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.

  9. trait WSTestRequestBuilding extends AnyRef

Deprecated Type Members

  1. class ActorSystemResource extends ExternalResource
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0.0) Use ActorSystemExtension (Jupiter Junit support) instead

  2. abstract class JUnitRouteTest extends JUnitRouteTestBase
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0.0) Use JUnitJupiterRouteTest instead

  3. 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

Value Members

  1. object WSProbe

Ungrouped