Last active
November 10, 2023 10:29
-
-
Save mbjelac/b30f68c2cb17376a095c33e061a71189 to your computer and use it in GitHub Desktop.
API test service config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imports... | |
@Configuration // for Spring's DI setup | |
class ApiTestDoubles( | |
private val factory: ApiTestDoubleFactory | |
) { | |
// 👇 one for each top-level service | |
@Bean // this method's return value will be in the DI context for others to use | |
fun users(): Users = factory | |
.createTestDouble(Users::class.java) // specify service class | |
.withMethod("create-user") { it.createUser(any()) } // define label for method | |
.withMethod("get-users") { it.getUsers(any()) } // define label for another method | |
.build() // build a test-double to use instead of 'Users' service | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The "labels" are attached to methods so we can stub or spy from the frontend.