Eclipse “Favorites” and JUnit 4 Static Imports Revised
After some time of using static imports workaround for JUnit 4 and EasyMock described earlier I came to the conclusion, that editing import "favorites" is not a good idea.
The problem is that when you include a class with static methods in Eclipse "favorites", then in Content Assistant you see hundred of those static methods. This maybe somewhat inconvenient. Moreover, Content Assistant hangs a bit longer before appearing.
From now on I am directly using class name like Assert.assert.. or EasyMock.expect.. instead of using static imports.
Eclipse and JUnit 4 Static Imports
Importing static JUnit 4 annotations in Eclipse is somewhat boring. The thing is that by default Eclipse doesn't import static fields or methods.
The most optimal way is to add junit.framework.Assert to "favorite" static types. Then, assertion methods will be seen in editor.
How to:
- Menu -> Window -> Preferences
- Java -> Editor -> Content Assist -> Favorites
- New Type:
junit.framework.Assert
P.S.: idea taken from http://blog.xebia.com/2008/10/12/eclipse-tip-keep-static-imports-for-junit-4/