When using JUnit for creating unit tests, I have always felt annoyed that Eclipse keeps on suggesting (or even auto-importing) junit.framework.Assert, which is actually a deprecated type but appears first in the list of import suggestions.
To disable this behavior, one has to change the so-called Access Rules for the JUnit library.
To do this:
- Right-click you project and select Build Path -> Configure…
- Switch to Libraries tab and locate the used junit.jar
- Select Access rules and press Edit.
- Add a new rule with the rule pattern junit/framework/Assert and set its access level to Forbidden.
- Make sure that the rule appears before the junit/framework/* rule, which permits any acccess.
Now, Eclipse should only provide for one import quick fix, when using Assert. Even “Organize Imports” (Ctrl+Shift+O) should automatically find the correct solution now.
Thanks to this Stackoverflow post for hinting me at this solution.