throws 節に複数の例外が書かれている JUnit テストメソッドを報告します。 このような節は不必要に冗長です。 テストメソッドは他のプロジェクトのコードからは呼び出されないため、これらの例外を個別に処理する必要はありません。

例:


  @Test
  public void testReflection() throws NoSuchMethodException,
      InvocationTargetException, IllegalAccessException {
    String result = (String) String.class.getMethod("trim")
        .invoke(" hello ");
    assertEquals("hello", result);
  }

複数の例外宣言を単一の例外に置換するクイックフィックスが提供されています。


  @Test
  public void testReflection() throws Exception {
    String result = (String) String.class.getMethod("trim")
        .invoke(" hello ");
    assertEquals("hello", result);
  }