-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
100 lines (82 loc) · 2.52 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
plugins {
id 'java-library'
id 'eclipse'
}
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.magicwerk.brownies:brownies-tools:0.9.15") {
exclude group: 'org.magicwerk.ext.org.w3c', module: 'dom'
}
testImplementation "org.magicwerk.magictest:magictest-ng:0.9.11"
testImplementation "com.github.javaparser:javaparser-core:3.25.8"
testImplementation "junit:junit:4.8.2"
testImplementation "com.google.guava:guava-testlib:32.1.2-jre"
}
// MagicTest
ext {
magicTestVerbose = true
magicTestAssertions = true
stopOnMagicTestError = false
excludeTests = []
}
/**
* Run tests using MagicTest.
* Per default, suite testng.xml is run if it exists.
* Otherwise use -P to control execution:
* - gradle magicTest -Ptestclass=myclass
* - gradle magicTest -Prun=org.magicwerk.brownies.core.reflect.ReflectToolsTest#testAnnotation
*/
task magicTest(type: JavaExec) {
group = "Verification"
description = "Run the unit tests with MagicTest"
main = "org.magictest.ng.MagicTestNG"
def myArgs = []
def myJvmArgs = []
def runArg = project.properties['run']
def saveArg = project.properties['save']
def testclassArg = project.properties['testclass']
def existsTestNgXml = file("./testng.xml").exists()
def run = true
if (runArg) {
myArgs = [ "-run", runArg]
} else if (saveArg) {
myArgs = [ "-save", saveArg]
} else if (testclassArg) {
myArgs = [ "-testclass", testclassArg]
} else if (existsTestNgXml) {
myArgs = [ "testng.xml" ]
} else {
run = false
}
onlyIf {
run
}
if (magicTestVerbose) {
myArgs << "-verbose" << "10"
}
if (magicTestAssertions) {
myJvmArgs << "-ea"
}
def excludeGroups = [ 'manual' ]
excludeGroups.addAll(excludeTests)
myArgs << "-excludegroups" << excludeGroups.join(',')
// Note: directly manipulating args and jvmArgs seems not work, so copy if all done
args = myArgs
jvmArgs = myJvmArgs
// Set system properties to make test output stable
systemProperty 'file.encoding', 'UTF-8'
systemProperty 'line.separator', '\r\n'
systemProperty 'user.timezone', 'Europe/Berlin'
systemProperty 'gradleMagicTest', 'true'
// classpath includes local tests
classpath = sourceSets.test.runtimeClasspath
// classpath does not include local tests
//classpath = configurations.testRuntimeClasspath
ignoreExitValue = !stopOnMagicTestError
doFirst {
mkdir "output"
println "Running MagicTest with arguments " + args + ", jvmArgs " + jvmArgs
}
}