-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Testing against interfaces instead of implementations #205
Comments
Cannot reproduce. MoreUnit jumps perfectly between the implementation and test, if the test is called FooImplTest and default settings are used. Generally speaking your suggestion is bad IMO. It's overly complex and cannot be generalized to a good and simple to understand rule for every Java project and Java developer out there. In my eyes your current test name is just lying, because the test doesn't test anything of the interface, but just its subclass implementation. If you want to "unify" the interface and implementation for easier navigation, then make the implementation a default implementation of the interface, or make the implementation a nested class of the interface, or... but don't try to bend the unit testing. There is nothing to test in an interface without default implementations. |
@Bananeweizen did you try all mentioned cases? At least jumping from Of course I was fearing you might find it a bad idea, as the general approach is issue of debates, like here: https://stackoverflow.com/questions/6724401/how-to-write-junit-tests-for-interfaces ... ;-) Anyhow: that's why I was mentioning the Arquillian setup I encountered in a lot of projects of a client of mine: they rely heavily on dependency injection in a maven multi module project, and they use interfaces for integration tests, in which concrete implementations from another module get injected into the Arquillian test. Plus: in such a situation you only want to focus the tests on the interface, not any implementation details. And default methods are out of the question, too, as the interfaces are generated code. You might dislike the whole architectural setup of these projects, but that's nothing I can change. One thing I don't quite understand:
The implementation might be somewhat complex, but what's not simple in a rule that says: "Ctrl-J jumps between test and implementation(s)." But I'm happy to discuss this further, hopefully it'll generate some more insights. |
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:
MoreUnit will:
If the test class is named FooImplTest, MoreUnit will
I propose to change the behaviour in such situations like the following:
MoreUnit will
Nice to have:
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?
The text was updated successfully, but these errors were encountered: