What is expected in JUnit?

What is expected in JUnit?

JUnit Expected Exception Test: @Test(expected)

JUnit offers you with a feature for tracing the exception. This can also let you know if the code throws an exception or if it doesn’t. Junit4 offers a simple and readable way to manage exception testing. You can choose: Optional parameter (expected) of @test annotation and for tracing the information , you can use ”fail()”. Get to know about expectMessage method of org.junit.rules.ExpectedException class: Use org.junit.rules.ExpectedException.expectMessage in junit with Examples | LambdaTest