catch 블록을 사용하여 억제되는 assert 문 및 테스트 프레임워크 어설션을 보고합니다. 던져진 AssertionError가 포착되어 확인 없이 무시되므로 그러한 어설션은 실패하지 않습니다.

예시 1:


  void javaAssertion() {
    try {
      ...
      assert 1 == 2;
    } catch (AssertionError e) {
      // the assertion is silently ignored
    }
  }

예시 2:


  @Test
  void testWithAssertJ() {
    try {
      ...
      assertThat(1).as("test").isEqualTo(2);
    } catch (AssertionError e) {
      // the assertion is silently ignored
    }
  }

예시 3:


  @Test
  void testWithJunit() {
    try {
      ...
      assertEquals(1, 2);
    } catch (AssertionError e) {
      // the assertion is silently ignored
    }
  }

2020.3의 새로운 기능