我想在我的Gradle构建(版本1.0)中添加集成测试.它们应该与我的正常测试分开运行,因为它们需要将webapp部署到localhost(它们测试该webapp).测试应该能够使用我的主要源集中定义的类.我该如何实现这一目标?
我正在使用这篇博文来配置Spring Boot项目的集成测试,但我非常坚持声明源集.我也在StackOverflow上发现了这篇文章,但我想我已经进一步了.
我的项目结构是
project
|_ src
|_ main
| |_ kotlin
| |_ resources
|_ testIntegration
| |_ kotlin
| |_ resources
|_ test
| |_ kotlin
| |_ resources
|_ build.gradle.kts
|_ ... other files
Run Code Online (Sandbox Code Playgroud)
和build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
idea
kotlin("jvm")
id("org.springframework.boot") version "2.0.5.RELEASE"
id("org.jetbrains.kotlin.plugin.spring") version "1.2.71"
}
fun DependencyHandlerScope.springBoot(module: String) = this.compile("org.springframework.boot:spring-boot-$module:2.0.5.RELEASE")
fun DependencyHandlerScope.springBootStarter(module: String) = this.springBoot("starter-$module")
dependencies {
springBoot("devtools")
springBootStarter("batch")
springBootStarter("... spring boot dependencies")
compile("... more dependencies")
testCompile("... more …Run Code Online (Sandbox Code Playgroud)