Using Mock for event listeners in unit-testing
- by phtrivier
I keep getting to test this kind of code (language irrelevant) :
public class Foo() {
public Foo(Dependency1 dep1) {
this.dep1 = dep1;
}
public void setUpListeners() {
this.dep1.addSomeEventListener(.... some listener code ...);
}
}
Typically, you want to test what when the dependency fires the event, the class under…