Closed sarahtattersall closed 10 years ago
It turns out Mockito can mock classes too, but this is still a good practice.
Agreed, especially when there are multiple possible implementations of an interface. For a single class, sometimes it's easier to subclass it, and override the method(s) that are making the test difficult. Some examples in the existing unit tests (private classes in the test class)...for discussion sometime...Steve
Steve Doubleday stevedoubleday@gmail.com 818-648-8381 twitter: sjdayday
On Oct 9, 2013, at 10:54 AM, Sarah Tattersall notifications@github.com wrote:
As a good rule of thumb, and to make use of mocks in testing PIPE should make use of interfaces where possible.
For example ArrayList x = new ArrayList();
would become List x = new ArrayList();
Method parameters also need to be changed to interfaces allowing them to be mocked. For example in TransitionView.java the method public TransitionView paste(double x, double y, boolean fromAnotherView, PetriNetView model) would be far better if PetriNetView was an interface and therefore mockable.
— Reply to this email directly or view it on GitHub.
Closing due to moving Petri Net logic to PIPECore
As a good rule of thumb, and to make use of mocks in testing PIPE should make use of interfaces where possible.
For example ArrayList x = new ArrayList();
would become List x = new ArrayList();
Method parameters also need to be changed to interfaces allowing them to be mocked. For example in
TransitionView.java
the methodpublic TransitionView paste(double x, double y, boolean fromAnotherView, PetriNetView model)
would be far better if PetriNetView was an interface and therefore mockable.