I would like the JUnit 4 test class to implement the same interface as its test class. Thus, as the interface changes (and it will be, we will be in an early development), the compiler ensures that the corresponding methods are added to the test class. For instance:
public interface Service { public String getFoo(); public String getBar(); } public class ServiceImpl implements Service { @Override public String getFoo() { return "FOO"; } @Override public String getBar() { return "BAR"; } } public class ServiceTest implements Service { @Override @Test public String getFoo() {
When I try to do this, I get an error: "java.lang.Exception: the getFoo () method must be invalid", presumably because the test methods should return a void. Does anyone know about this?
source share