Skip to content

A HTTP layer mocking framework for testing Kotlin applications

License

Notifications You must be signed in to change notification settings

rama-nallamilli/mockee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MocKee

Build Status

A HTTP layer mocking framework for Kotlin, inspired by Wiremock. This library is currently a work in progress.

  • a Kotlin fluent DSL
  • low dependency framework

Mocking a GET request

Create a mock request

val myMockedRequest =
mock {
    get {
        url("/my-app/users")
        header("x-session-id", UUID.randomUuid)
        header("x-client-id", "customer-a")

        response {
            header("Content-Type", "application/json")
            status(200)
            stringBody("{ LOL BODY }") | jackson(a: T) | fn(request -> {})
        }
    }
}

Submit mock request to run

    val mockServer = Server(port = 1234)

    // mock is removed after lambda runs (successful or not)
    mock(requests = myMockedRequest, server = mockServer) {
        val service = MyService()
        service.call()
    }

    //mock stays persistent until user runs remove mock
    globalMock(requests = myMockedRequest, server = mockServer)


    //clears mock
    clearMock(requests = myMockedRequest, server = mockServer)

Work in progress

See work in progress

About

A HTTP layer mocking framework for testing Kotlin applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages