Spring Boot application test class

The following code snippet shows the generated SpringBootApplicationTest class, FirstWebServiceWithKotlinApplicationTests:

    @RunWith(SpringRunner::class)
@SpringBootTest
class FirstWebServiceWithKotlinApplicationTests {
@Test
fun contextLoads() {
}
}

The following are a few important things to note:

  • Package, import, and annotations are the same as that of a Java class.
  • :: is used to obtain a Kotlin class runtime reference. Compared to @RunWith(SpringRunner.class) in Java, the Kotlin code uses @RunWith(SpringRunner::class).
  • The declaration of the test class uses the Kotlin function syntax.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset