A good unit test should be:
It is always better to follow such rules:
- use real code for system's under test dependencies
- if not possible, replace it with test double (like in-memory database)
- if not possible, replace it with mock object
- never test behaviour (method X was invoked), test state or returned result
I really like these guidances. Will incorporate them.
What are some example unit test names? I am not clearly understanding the name format but examples would definitely help
Maybe something like "When user fill incorrect email format, it should show invalid email format error"
Here is an example:
testWhenEmailFormatIsInvalidShouldShowValidationError
It is always better to follow such rules:
- use real code for system's under test dependencies
- if not possible, replace it with test double (like in-memory database)
- if not possible, replace it with mock object
- never test behaviour (method X was invoked), test state or returned result
I really like these guidances. Will incorporate them.
What are some example unit test names? I am not clearly understanding the name format but examples would definitely help
Maybe something like "When user fill incorrect email format, it should show invalid email format error"
Here is an example:
testWhenEmailFormatIsInvalidShouldShowValidationError