Mark unit test as an expected failure in JUnit

后端 未结 6 1929
滥情空心
滥情空心 2020-12-09 01:05

How can I mark a test as an expected failure in JUnit 4?

In this case I want to continue to run this test until something is patched upstream. Ignoring the test goes

6条回答
  •  春和景丽
    2020-12-09 01:38

    What about explicitly expecting an AssertionError?

    @Test(expected = AssertionError.class)
    public void unmarshalledDocumentHasExpectedValue() {
        // ...
    }
    

    If you're reasonably confident that only the JUnit machinery within the test would raise AssertionError, this seems as self-documenting as anything.

    You'd still run the risk of forgetting about such a test. I wouldn't let such tests into version control for long, if ever.

提交回复
热议问题