Total Pageviews

2020/06/04

[Java] [JUnit] How to expect no exception is thrown?

Before

1
2
3
4
    @Test
    public void testWritePropertyFile() {
        fileGeneratorService.writePropertyFile();
    }


After

1
2
3
4
5
    @Test
    public void testWritePropertyFile() {
        Assertions.assertThatCode(() -> fileGeneratorService.writePropertyFile())
                  .doesNotThrowAnyException();
    }




No comments: