-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle.kts
62 lines (52 loc) · 1.78 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
jacoco
kotlin("jvm") version "2.0.20"
}
group = "com.example"
version = "1.0"
configurations {}
val cucumberRuntime by configurations.creating {
extendsFrom(configurations["testImplementation"])
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("io.cucumber:cucumber-java:7.18.1")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.0")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
task("cucumber") {
dependsOn("assemble", "compileTestJava")
doLast {
javaexec {
mainClass.set("io.cucumber.core.cli.Main")
classpath = cucumberRuntime + sourceSets.main.get().output + sourceSets.test.get().output
// Change glue for your project package where the step definitions are.
// And where the feature files are.
args = listOf("--plugin", "pretty", "--glue", "com.example.feature", "src/test/resources")
// Configure jacoco agent for the test coverage.
val jacocoAgent = zipTree(configurations.jacocoAgent.get().singleFile)
.filter { it.name == "jacocoagent.jar" }
.singleFile
jvmArgs = listOf("-javaagent:$jacocoAgent=destfile=$buildDir/results/jacoco/cucumber.exec,append=false")
}
}
}
tasks.jacocoTestReport {
// Give jacoco the file generated with the cucumber tests for the coverage.
executionData(files("$buildDir/jacoco/test.exec", "$buildDir/results/jacoco/cucumber.exec"))
reports {
xml.required.set(true)
}
}