Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Static Imports in Eclipse with Quick Fix

DZone's Guide to

Static Imports in Eclipse with Quick Fix

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

Not sure what is so complicated about static imports that eclipse can still not get support for them straight, even in 3.5M7. Using hamcrest and even JUnit 4 is made much more unpleasant than it should be by the fact that getting these things into tests is such a nuisance. For instance, I do a simple assertThat statement, then use equalTo or closeTo, and I would like to be able to do just Apple-Shift-O (Organize Imports) and get all those things put in. That doesn‘t work. Next best thing would be to just go to each instance and do Apple-1. That does work once in a while, but not most of the time.

Today, I did some searches and found the suggestion of adding the types (e.g. org.junit.Assert) to the favorites tab or Content Assist.

What this does, is it makes it possible for you to get the suggestion inline and if you take it, it will add the import,

but Organize Imports still doesn‘t work:

The other solution, of course, would be to just add the imports to the template that the junit plugin is using (should be a super simple, configurable choice, but alas, it is not).

So this is better than not having the content assist working, but still not optimal.

From http://www.jroller.com/robwilliams/

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. Our APIs verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – to ensure accurate delivery, prevent blacklisting and identify risks in real-time.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}