• Types of test doubles,
    • Dummies
    • Stubs
    • Spies
    • Mocks
    • Fakes

Example

Consider the below code snippet,

interface Authorizer {
  public Boolean authorize(String username, String password);
}
 
public class System {
	public System(Authorizer authorizer) {
		this.authorizer = authorizer;
	}
	
	public int loginCount() {
		//returns number of logged in users.
	}
}
public class DummyAuthorizer implements Authorizer {
 
	public Boolean authorize(String username, String password) {
		return null
	}
}
 

Refs

  1. https://blog.cleancoder.com/uncle-bob/2014/05/14/TheLittleMocker.html