We recently upgraded to JUnit 4.13 and my project was painted warning yellow because Assert.assertThat
has now been deprecated in favour of MatcherAssert.assertThat
.
Bulk changing my static imports is no big deal but I was hoping that going forward I could configure Eclipse to do the right thing in new code. But no matter what I do, the auto importer continues to pull in the deprecated Assert.assertThat
instead of the MatcherAssert
one.
Some things I've tried:
Add org.hamcrest.MatcherAssert.*
to Preferences -> Java -> Editor -> Content Assist -> Favorites. Now I see MatcherAssert.assertThat
as a quick fix suggestion when there is no import and I mouse over the code. But this doesn't affect the automatic imports at all.
Add org.junit.Assert.assertThat
to Preferences -> Java -> Appearance -> Type Filters. (I've also tried org.junit.Assert.*
and even org.junit.*
) This seems to have no effect on static imports. I can see the setting taking effect on regular imports when I experimented with org.junit.*
but nothing on static imports.
So no matter what I do, when I hit save without explicitly pulling in MatcherAssert.assertThat
, the auto import pulls Assert.assertThat
instead.
Do you know if there is some way around this?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…