• 0 Posts
  • 1 Comment
Joined 2Y ago
cake
Cake day: Apr 10, 2022

help-circle
rss

It means do not test HOW it is done, only test WHY it is done. Obviously you cannot test an abstract interface, only an implemented one. However, you should not be testing HOW it is implemented. Instead, you should be testing that given X input you get Y output based on the expectations set in the interface.

For example, take method F(x, y) that is designed to take in an identifier x and use it to fetch you a record from some persistence object y. Testing the interface of F(x, y) would mean testing that given the input x you get what you expect from the persistence object y. Testing the implementation would mean testing that F(x, y) issues a call to a specific method of y. For example, if y has an interface with methods getRecordById, getAllRecords, and searchRecords, testing the implementation means asserting which of these methods gets called (usually with a test using a mock object that can be interrogated in this way). Testing the interface means not caring which of these methods are called when satisfying the request for F(x, y)