Reputation: 1074
If testing my method which is supposed to return a value based on a certain criteria (maybe it's validating credentials)
testAuthenticate_ValidCredentials_ReturnTrue
Should I also write separate methods to test whether it returns the correct value if the criteria isn't met?
testAuthenticate_InValidCredentials_ReturnFalse
In other words, should I run multiple tests per method?
Upvotes: 1
Views: 296
Reputation: 3055
yes, it is better to tailor each test to check only one funcational aspect of your code, so separate tests for valid (authenticated) and invalid (rejected) credentials is the proper approach.
As to the larger issue of how many tests to write total, ideally you want to run every source line in the code being tested.
Upvotes: 2