title: how to test that a method throws an exception junit5
body: <p>I have a <code>DocumentTypeDetector</code> class that has a <code>detectForRequest()</code> method.
  I'm doing the corresponding tests, but I have not been able to verify that a customized exception is thrown, I'm using JUNIT 5.</p>
  
  <p>I have reviewed here, but the answers have not helped me, this is the code I have written following an example:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Test
  public void tryThrowExceptionForInvalidRequest() throws Exception{
  
      InvalidInputRequestType exceptionThrown = Assertions.assertThrows(
              InvalidInputRequestType.class,
              () -&gt; { 
                  throw new InvalidInputRequestType("La petición debe estar en un formato valido JSON o XML"); 
              }
      );
      assertEquals("La petición debe estar en un formato valido JSON o XML", exceptionThrown.getMessage());
  }
  </code></pre>
  
  <p>But this does not tell me anything about my test</p>
  
  <p>I need to verify that my method returns the corresponding exception, something like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Test
  public void tryThrowExceptionForInvalidRequest() throws Exception{
      String invalid = "Este es un request invalido";
      assertIsThrown(InvalidInputRequestType.class, detector.detectForRequest(invalid));
  }
  </code></pre>
  
  <p>How can I test this?</p>