api

http4k / org.http4k.testing

Package org.http4k.testing

Useful tools for testing http4k applications.

Types

Name Summary
ApprovalContent interface ApprovalContent
Determines which parts of the HttpMessage will be compared.
ApprovalSource interface ApprovalSource
The backing store where the approved and actual content will be stored.
ApprovalTest class ApprovalTest : BaseApprovalTest
Standard Approval JUnit5 extension. Can be used to compare any HttpMessages.
Approver interface Approver
Coordinates the comparison of the content for a test.
BaseApprovalTest interface BaseApprovalTest : BeforeTestExecutionCallback, ParameterResolver
Base JUnit extension for injecting an Approver into a JUnit5 test-case. Implement this to provide custom approval behaviours, or
ContentTypeAwareApprovalTest abstract class ContentTypeAwareApprovalTest : BaseApprovalTest
Approval testing JUnit5 extension that checks the expected content type is present in the
FileSystemApprovalSource class FileSystemApprovalSource : ApprovalSource
HtmlApprovalTest class HtmlApprovalTest : ContentTypeAwareApprovalTest
Approval JUnit5 extension configured to compare prettified-HTML messages. Note that this strips
JsonApprovalTest class JsonApprovalTest : ContentTypeAwareApprovalTest
Approval JUnit5 extension configured to compare prettified-JSON messages.
NamedResourceApprover class NamedResourceApprover : Approver
ReadResource interface ReadResource
ReadWriteResource interface ReadWriteResource : ReadResource
RecordingEvents class RecordingEvents : Events, Iterable<Event>
Simple recording events that can be used in tests
TestNamer interface TestNamer
Provides the identification of test case.
TestWsClient class TestWsClient : WsClient
A class that is used for offline testing of a routed Websocket, without starting up a Server. Calls are routed synchronously to the receiving Websocket, and error are propagated to the caller.
XmlApprovalTest class XmlApprovalTest : ContentTypeAwareApprovalTest
Approval JUnit5 extension configured to compare prettified-XML messages.

Exceptions

Name Summary
ApprovalFailed class ApprovalFailed : RuntimeException
ClosedWebsocket data class ClosedWebsocket : Exception

Extensions for External Classes

Name Summary
kotlin.Function1  

Functions

Name Summary
assertApproved fun Approver.assertApproved(response: Response, expectedStatus: Status): Unit
hasApprovedContent fun <T : HttpMessage> Approver.hasApprovedContent(): Matcher<T>
Create a Hamkrest Matcher for this message that can be combined with other Matchers
testWsClient fun PolyHandler.testWsClient(request: Request): TestWsClient?