Imagine a twitter-like app where users are allowed to follow to a limited amount of users; say 100.
I have this code:
fun follow(followerId: String, followedId: String) {
if (repo.countFollowing(followerId) >= 100) {
throw MaxFollowingReached()
}
repo.insertFollowingRelationship(followerId, followedId)
}
And this test case:
@Test
fun `users can following a maximum of 100 users`() {
val followerId = "1"
val followedId = "2"
val repo = mockRepository()
when(repo.countFollowing(followerId)).thenReturn(100)
service = Service(repo)
assertThrows {
service.follow(followerId, followedId)
}
}
As you see, the number 100
is present in the test name. Is this a good practice? Or should I avoid it and write a "more generic" test?