-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Currently MoreUnit matches implementing classes and corresponding tests.
It doesn't work if you want to test against an interface, e.g. if you have a setup like a client of mine with Arquillian and dependency injection into interface-typed properties.
Consider a setup like the following three types:
public interface Foo {
int bar();
}
public class FooImpl implements Foo {
@Override
public int bar() {
return 0;
}
}
public class FooTest {
@Test
void testBar() throws Exception {
Foo foo = new FooImpl();
Assertions.assertEquals(foo.bar(), 1);
}
}MoreUnit will:
- jump from Foo to FooTest (correct),
- jump from FooTest to Foo (undesired),
- not jump anywhere from FooImpl, but propose to create a new test class (undesired).
If the test class is named FooImplTest, MoreUnit will
- not jump anywhere from Foo, but propose to create a new test class (undesired),
- jump from FooImpl to FooImplTest (correct),
- jump from FooImplTest to Foo (undesired).
I propose to change the behaviour in such situations like the following:
MoreUnit will
- jump from Foo to FooTest,
- jump from FooTest to FooImpl,
- jump from FooImpl to FooTest,
- if the test class is named FooImplTest, the equivalent behaviour should occur.
Nice to have:
- if there are several implementations of the interface available, jump to the concrete implementation used, if it can be determined directly/easily,
- if such a definite resolution cannot be made, offer a selection of target classes.
I'm not sure how best to implement this yet, and would be happy to get some ideas. Two ideas popping my head (without checking the source code for feasibility yet) are either to have a special naming pattern matching in settings to find the right class, or to identify if a type is an interface, and then change the logic of the jumping accordingly.
Any more ideas/suggestions?