title: JUnit: Enable assertions in class under test
body: <p>I've been bit a few times by Java <code>assert</code> statements that didn't fail in the JUnit test suite because assertions weren't enabled in JUnit's JVM instance. To be clear, these are "black box" assertions inside implementations (checking invariants, etc) not the assertions defined by the JUnit tests themselves. Of course, I'd like to catch any such assertion failures in the test suite.</p>
  
  <p>The obvious solution is to be <em>really careful</em> to use <code>-enableassertions</code> whenever I run JUnit, but I'd prefer a more robust solution. One alternative is to add the following test to every test class:</p>
  
  <pre><code>  @Test(expected=AssertionError.class)
    public void testAssertionsEnabled() {
      assert(false);
    }
  </code></pre>
  
  <p>Is there a more automatic way to accomplish this? A system-wide configuration option to JUnit? A dynamic call I could put in the <code>setUp()</code> method? </p>