3
How to write a test for the Application class in Spring Boot for Kotlin
source link: https://stackoverflow.com/questions/75200943/how-to-write-a-test-for-the-application-class-in-spring-boot-for-kotlin
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to write a test for the Application class in Spring Boot for Kotlin
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class GetThingsDoneApplication
fun main(args: Array<String>) {
runApplication<GetThingsDoneApplication>(*args)
}
I am trying to push my test coverage for my project to 100%. But I don't know how to write a test for main(args: Array<String>)
I guess the Test Class and method should look something like this:
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
@ContextConfiguration(classes = [GetThingsDoneApplication::class])
class GetThingsDoneApplicationIntegrationTest {
@Test
fun contextLoads() {
main(doSomething())
}
private fun doSomething(): Array<String> {
return arrayOf<String>()
}
}
The question is now, how should my assertThat
look like, to have 100% test coverage?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK