I wrote the MyInterface interface, which will be implemented by different developers.
I also wrote the MyInterfaceTest class, which contains common test methods that all developers should be able to use to test their implementations.
I just don't know how to make it work as a JUnit test.
I currently have something like this:
public class MyInterfaceTest { private static MyInterface theImplementationToTest = null; @BeforeClass public static void setUpBeforeClass() throws Exception {
I use the static setUpBeforeClass method because it takes a long time to initialize each implementation, so I want to initialize it once for all tests.
In this test version, developers must modify the setUpBeforeClass code and place their own implementation.
I am sure there is another way to write MyInterfaceTest , so developers will only need to inherit it or send it a parameter, and not change the code. However, I'm not experienced enough at JUnit to get it to work. Could you show me how to do this?
Erel segal-halevi
source share