Dallin
Dallin

Reputation: 1074

How many test methods should I run per method?

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

Answers (1)

Andras
Andras

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

Related Questions