Usually, I only have one implementation of an interface in my application and that first implementation is always used when writing the tests for the interface. Let's say I have an interface Destroyer
and an implementation DestroyerImpl
. Then I would use that class in the test:
class DestroyerTest
{
private Destroyer destroyer = new DestroyerImpl();
@Test
public void test() { ... }
}
The class is then implicitly tested by being instantiated in the testing of the interface.
If I write another implementation class EpicDestroyer
I now feel like I have to test that as well.
So, do I write two test classes DestroyerImplTest
and EpicDestroyerTest
that both test the same Destroyer
interface with different implementations? Wouldn't that be redundant? I could test each implementation in the same test suite by parameterizing it. Is this the way to do it?