-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
104 lines (80 loc) · 2.86 KB
/
build.gradle
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
apply plugin: 'application'
///////////////////////////////////////////////////////////////////////////
// Definint Main class
///////////////////////////////////////////////////////////////////////////
mainClassName = 'main.java.Main'
///////////////////////////////////////////////////////////////////////////
// Repositories and dependencies for code go here
///////////////////////////////////////////////////////////////////////////
repositories {
mavenCentral()
}
///////////////////////////////////////////////////////////////////////////
// JUnit 5 include
///////////////////////////////////////////////////////////////////////////
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath ("org.junit.platform:junit-platform-gradle-plugin:1.0.0-M4")
}
}
apply plugin: 'org.junit.platform.gradle.plugin'
dependencies {
// in case JUnit 4 is also needed/wanted
compile("junit:junit:4.12")
testRuntime("org.junit.vintage:junit-vintage-engine:4.12.0-M4")
testCompile("org.junit.jupiter:junit-jupiter-api:5.0.0-M4")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.0-M4")
// Enable use of the JUnitPlatform Runner within the IDE
testCompile("org.junit.platform:junit-platform-runner:1.0.0-M4")
}
junitPlatform {
details 'tree'
}
apply plugin: 'jacoco'
afterEvaluate {
def junitPlatformTestTask = (JavaExec) project.tasks.getByName('junitPlatformTest')
jacoco {
applyTo(junitPlatformTestTask)
}
project.task(type: JacocoReport, "jacocoJupTestReport") {
executionData(junitPlatformTestTask)
sourceSets(sourceSets.main)
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
classDirectories = files(sourceSets.main.output)
reports {
xml.enabled true
xml.destination file("${buildDir}/jacoco/report.xml")
html.enabled true
html.destination file("${buildDir}/jacoco/html")
}
}
check.dependsOn jacocoJupTestReport
}
configurations {
junitXmlToHtml
}
task generateHtmlTestReports << {
def reportsDir = new File(buildDir, 'test-reports')
reportsDir.mkdirs()
ant.taskdef(
name: 'junitReport',
classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
classpath: configurations.junitXmlToHtml.asPath
)
ant.junitReport(todir: "$buildDir/test-results/junit-platform", tofile: "aggregated-test-results.xml") {
fileset(dir: "$buildDir/test-results/junit-platform")
report(format: 'frames', todir: reportsDir)
}
}
afterEvaluate {
def junitPlatformTestTask = tasks.getByName('junitPlatformTest')
generateHtmlTestReports.dependsOn(junitPlatformTestTask)
check.dependsOn(generateHtmlTestReports)
}
dependencies {
// configure as normal ...
junitXmlToHtml 'org.apache.ant:ant-junit:1.9.7'
}