How do you test exceptions in JUnit 5?

How do you test exceptions in JUnit 5?

In Junit5 assertThrows method is for handling expected exception on that particular Method . Here is the Syntax Exception exception = assertThrows(NumberFormatException.class, () → { Integer.parseInt(“1a”); });

https://www.baeldung.com/junit-assert-exception