title: How to fail a test after a timeout is exceeded in JUnit 5?
body: <p>In JUnit 4 the "timeout" annotation parameter can be used to force a test to stop after the given amount of time:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Test(timeout=100)
  public void infinity() {
     while(true);
  }
  </code></pre>
  
  <p>How can this be done in JUnit 5?</p>
  
  <p>Closely related to (and code taken from) <a href="https://stackoverflow.com/questions/7015032/timeout-parameter-for-annotation-type-test">timeout parameter for Annotation Type Test</a>, but for JUnit 5.</p>