Below you will find pages that utilize the taxonomy term “Contract Tests”
Blog Posts
State vs. Behaviour Verification
Suppose we have the following interface:
interface Validator { fun validate(query: String): Boolean } and suppose it’s being used as a collaborator in a few places:
class FindItems( val validator: Validator, val repository: Repository ) { fun search(keyword: String) { if (validator.validate(keyword)) { repository.findItemsContaining(keyword) } } } class DeleteItems( val validator: Validator, val repository: Repository ) { fun deleteMatches(value: String) { if (validator.validate(value)) { repository.deleteItemsMatching(value) } } } Of course, we would have some tests for these functionalities, which might look something like this respectively: