canCreateNewUsers
is an implementation detail for createUsers
. Write your tests accordingly.
In other words, your unit tests for createNewUserscreateUsers
should include some test cases that exercise the permissions function canCreateUserscanCreateNewUsers
provides, within the context ofcreateUsers
.
You don't have to write these additional tests if:
- You are already satisfied by the original unit tests that
createUserscanCreateNewUsers
functions properly, and - You are already convinced that you are calling
createUserscanCreateNewUsers
properly so that it functions correctly in the context in which you are calling it.
But your fellow software developers aren't necessarily thinking about these things. Wouldn't it be nice if you had a test for createUsers
that fails if someone else makes a change to canCreateNewUsers
that breaks your code?