How to write JUnit test cases in Spring Boot
What you will learn here about Spring Boot
- How to write JUnit test cases in Spring Boot
How to write JUnit test cases in Spring Boot
It is very easy to write junit test case in spring boot. The way we write test case in maven project same way we can write test case in Spring boot. So here we will see how to write junit test cases in spring boot.
1)Assuming you have created spring boot maven project
2)Please add junit maven dependency in pom.xml which is shown below
3)Now please create a class whose test case you want to create
4)Now please follow the following steps
- Right click anywhere in the class editor
- Click on Generate
- click on Test
5)Please tick methods whose test case you want to create and click on OK which is shown below
6)Now please write the test case which is shown below
7)Once you complete the test case. please run the test case
8)If test is successfull then you will see Tests passed which is shown below