Test Behaviors not Methods
Learn about the importance of focusing on class behaviors and ignoring methods.
We'll cover the following
When we write tests, focus on the behaviors of our class, not on testing the individual methods.
Scenario: ATM
class
To understand what that means, think about the tedious but time-tested example of an ATM class for a banking system. Its methods include deposit()
, withdraw()
, and getBalance()
. We might start with the following tests:
makeSingleDeposit
makeMultipleDeposits
Get hands-on with 1400+ tech skills courses.