How to test that no exception is thrown

What you will learn here about Junit

  • How to test that no exception is thrown

Here we will see how to test np exception test or how to test that no exception is thrown in Junit

How to test that no exception is thrown

It is very easy to test that exception is not thrown in java. Please follow the following steps to know how to test that no exception is thrown.
1)First creating a maven project

2)Add Junit dependency in your POM.xml of your maven project which is shown below
junit maven dependency

3)Create a class whose test case you want to create which is shown below
junit assert no exception

4)Now create a test case for your class
How to test that no exception is thrown

You may also like...