Assert.assertEquals()Assert.assertTrue() などのメソッドの呼び出しのうち、Hamcrest 宣言スタイルの Assert.assertThat() の呼び出しに移行できるものを報告します。

例:


  public class SubstantialTest {
    @Test
    public void testContents(Collection<String> c, String s) {
      Assert.assertTrue(c.contains(s));
      Assert.assertEquals(c, s);
      Assert.assertNotNull(c);
      Assert.assertNull(c);
      Assert.assertFalse(c.contains(s));
    }
  }

このような移行を実行するためのクイックフィックスが提供されています。


  public class SubstantialTest {
    @Test
    public void testContents(Collection<String> c, String s) {
      assertThat(c, hasItem(o));
      assertThat(o, is(c));
      assertThat(c, notNullValue());
      assertThat(c, nullValue());
      assertThat(c, not(hasItem(o)));
    }
  }

このインスペクションを使用するには、クラスパスで Hamcrest ライブラリにアクセスできる必要があります。

Hamcrest の matcher メソッドを static インポートするクイックフィックスを実行するかどうかを指定するには、「Matcher のメソッドを static インポートする」オプションを使用します。