Package ratpack.test

Interface CloseableApplicationUnderTest

    • Method Detail

      • test

        default void test​(Action<? super TestHttpClient> action)
                   throws Exception
        Provides the given action with a test http client for this application, then closes this application.

        The application will be closed regardless of whether the given action throws an exception.

         import ratpack.test.embed.EmbeddedApp;
         import static org.junit.jupiter.api.Assertions.assertEquals;
         public class Example {
           public static void main(String... args) throws Exception {
             EmbeddedApp.fromHandler(ctx ->
             ).test(httpClient ->
               assertEquals("ok", httpClient.get().getBody().getText())
        action - an action that tests this embedded application
        Exception - any thrown by action
      • close

        void close()
        Shuts down the application under test.

        The exact meaning of invoking this method is implementation dependent.

        Specified by:
        close in interface AutoCloseable