For unit testing, we are using a JUnit, which is a popular Java-based unit testing library. The following source code shows the example skeleton of the Spring Boot test class. The @SpringBootTest annotation specifies that the class is a regular test class that runs Spring Boot based tests. The @Test annotation before the method defines to JUnit that the method can be run as a test case. The @RunWith(SpringRunner.class) annotation provides Spring ApplicationContext and get beans injected into your test instance:
@RunWith(SpringRunner.class)@SpringBootTestpublic class MyTestsClass { @Test public void testMethod() { ... }}
First, we will create our first test case, which will test the major functionality of your application ...