title: Mark unit test as an expected failure in JUnit
body: <p>How can I mark a test as an expected failure in JUnit 4?</p>
  
  <p>In this case I want to continue to run this test until something is patched upstream. Ignoring the test goes a little too far, as then I might forget about it. I may be able to add an <code>@expected</code> annotation and catch the exception thrown by <code>assertThat</code>, but that also seems to lie about the expected behavior.</p>
  
  <p>Here's what my current test looks like:</p>
  
  <pre><code>@Test
  public void unmarshalledDocumentHasExpectedValue() 
  {
      doc = unmarshaller.unmarshal(getResourceAsStream("mydoc.xml"));
      final ST title = doc.getTitle();
      assertThat(doc.getTitle().toStringContent(), equalTo("Expected"));
  }
  </code></pre>
  
  <p>That assert should succeed, but because of an upstream bug it doesn't. Yet, that test is correct; it should succeed.  Virtually all the alternatives that I've found are misleading.  Right now I think <code>@Ignore("This test should pass once fixed upstream")</code> is my best bet, but I still have to remember to come back to it. I'd prefer that the test run.</p>
  
  <p>In Python I can use the <a href="http://docs.python.org/dev/library/unittest.html#unittest.expectedFailure" rel="noreferrer">expectedFailure</a> decorator:</p>
  
  <pre><code>class ExpectedFailureTestCase(unittest.TestCase):
      @unittest.expectedFailure
      def test_fail(self):
          self.assertEqual(1, 0, "broken")
  </code></pre>
  
  <p>With Qt's <a href="https://doc.qt.io/qt-4.8/qtestlib-manual.html#qtestlib" rel="noreferrer">QTestLib</a> in C++, you can use <a href="https://doc.qt.io/qt-5/qtest.html#QEXPECT_FAIL" rel="noreferrer">QEXPECT_FAIL</a>:</p>
  
  <pre><code>QEXPECT_FAIL("", "Will be fixed next version", Continue);
  QCOMPARE(i, 42);
  </code></pre>
  
  <p>In both cases above, the unit test runs which is what I'm hoping to have happen. Am I missing something in JUnit?</p>