sam
04/18/2022, 12:09 PMthanksforallthefish
04/19/2022, 6:24 AMclass UserApplicationService(
val dataStore: UserDataStore,
val validator: Validator
) {
fun create(userDetails: UserDetails) {
val user = convert(userDetails)
validator.throwWhenInvalid(user)
dataStore.insert(user)
}
private fun convert(userDetails: UserDetails) = ....
}
you can ofc inject the “real” dataStore (ie: backed by test container), but at that point as soon as you application grows duration of these unitigration (nice term btw) becomes unbearable, especially for local development (I guess in CI you can smart starters that starts all needed container once before)
my team actually uses a similar approach, we start a small spring context for testing repositories and we run testcontainer for those, but we still need mocks when it comes to business logic teststhanksforallthefish
04/19/2022, 6:27 AMRob Elliot
04/19/2022, 7:13 AMRob Elliot
04/19/2022, 7:14 AMthanksforallthefish
04/19/2022, 7:18 AM