Spring Boot:编写一个 Hello World 应用(Kotlin & Gradle)( 十 )

3

响应成功,并返回内容为:Hello, World!。

3.5. 单元测试

3.5.1. 编写测试用例

src/test/kotlin/org/springdev/guides/helloworld/HelloControllerTests.kt

package org.springdev.guides.helloworld

import org.junit.Test

import org.junit.runner.RunWith

import org.springframework.beans.factory.annotation.Autowired

import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest

import org.springframework.test.context.junit4.SpringRunner

import org.springframework.test.web.servlet.MockMvc

import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get

推荐阅读