Best way of logging exceptions when tests fail (e.g. using a junit rule)

前端 未结 3 1706
孤独总比滥情好
孤独总比滥情好 2021-01-13 07:54

When I\'m running a complete test suite, it would be helpful if exceptions that caused a test to fail would appear in my (SLF4J-)log. What is the best method to achieve this

3条回答
  •  清歌不尽
    2021-01-13 08:30

    This seems so easy that I think I am wrong and you are asking something different, but maybe I can help:

    JUnit 4.X

    @Test(expected=Exception.class)

    is going to pass the test if the exception is thrown in the test, or fail with a message captured by the Junit framework

提交回复
热议问题