-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
144 lines (118 loc) · 5.18 KB
/
build.gradle
File metadata and controls
144 lines (118 loc) · 5.18 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
plugins {
id 'java'
id 'idea'
id 'io.qameta.allure' version '2.9.6'
id "org.gradle.test-retry" version "1.4.0"
}
compileJava { options.encoding = "UTF-8" }
group 'pl.databucket.tests'
version '1.0'
repositories {
mavenCentral()
}
allure {
version = "2.17.3"
}
sourceCompatibility = 11
targetCompatibility = 11
def junit5Version = '5.8.2'
def allureVersion = '2.17.3'
def lombokVersion = '1.18.24'
def jacksonVersion = '2.13.2'
def slf4jVersion = '1.7.36'
dependencies {
testImplementation(platform("org.junit:junit-bom:${junit5Version}"))
testImplementation "org.junit.jupiter:junit-jupiter:${junit5Version}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit5Version}"
implementation "org.junit.jupiter:junit-jupiter-api:${junit5Version}"
testRuntimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
implementation "org.projectlombok:lombok:${lombokVersion}"
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation "com.fasterxml.jackson.core:jackson-databind:2.13.2.2"
implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonVersion}"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jacksonVersion}"
implementation "io.qameta.allure:allure-java-commons:${allureVersion}"
testImplementation "io.qameta.allure:allure-junit5:${allureVersion}"
implementation 'com.sun.jersey:jersey-client:1.19.4'
implementation 'com.google.code.gson:gson:2.9.0'
}
task beforeTest {
doFirst {
if (System.getProperty("env") == null)
System.setProperty("env", "dev")
// Read and flatten global configuration
ConfigObject conf = new ConfigSlurper(System.getProperty("env")).parse(file('config.groovy').toURI().toURL()) as ConfigObject
try (FileOutputStream fos = new FileOutputStream("build/test.properties")) {
Properties props = new Properties()
conf.flatten().each { key, value -> props.setProperty("" + key, "" + value) }
props.store(fos, "Initial test configuration")
} catch (IOException e) {
println "${e.getMessage()}"
}
}
}
test {
ignoreFailures = true
testLogging.showStandardStreams = true
def threads = 1
if (System.getProperty("threads") != null)
threads = System.getProperty("threads")
else
System.setProperty("threads", threads.toString())
systemProperties = [
'junit.jupiter.execution.parallel.enabled' : true,
'junit.jupiter.execution.parallel.mode.default' : 'concurrent',
'junit.jupiter.execution.parallel.config.strategy' : 'fixed',
'junit.jupiter.execution.parallel.config.fixed.parallelism': threads
]
useJUnitPlatform {
if (System.getProperty("testPattern") != null)
filter.includeTestsMatching(System.getProperty("testPattern"))
if (System.getProperty("includeTags") != null)
includeTags(System.getProperty("includeTags").split(","))
if (System.getProperty("excludeTags") != null)
excludeTags(System.getProperty("excludeTags").split(","))
}
def confMaxRetries = 0
if (System.getProperty("maxRetries") != null)
confMaxRetries = Integer.parseInt(System.getProperty("maxRetries"))
System.setProperty("maxRetires", confMaxRetries.toString())
def confMaxFailures = 20
if (System.getProperty("maxFailures") != null)
confMaxFailures = Integer.parseInt(System.getProperty("maxFailures"))
System.setProperty("maxFailures", confMaxFailures.toString())
retry {
maxRetries = confMaxRetries
maxFailures = confMaxFailures
failOnPassedAfterRetry = false
filter {
includeAnnotationClasses.add("*Retryable")
excludeAnnotationClasses.add("*NonRetryable")
}
}
}
task afterTest {
doFirst {
final String PROPERTIES_PATH = "build/allure-results/environment.properties"
try (FileOutputStream fos = new FileOutputStream(PROPERTIES_PATH)) {
Properties props = new Properties()
props.setProperty("Environment", System.getProperty("env"))
props.setProperty("Threads", System.getProperty("threads"))
props.setProperty("Max retries", System.getProperty("maxRetires"))
props.setProperty("Max failures", System.getProperty("maxFailures"))
if (System.getProperty("includeTags") != null)
props.setProperty("Include tags", System.getProperty("includeTags"))
if (System.getProperty("excludeTags") != null)
props.setProperty("Exclude tags", System.getProperty("excludeTags"))
if (System.getProperty("testPattern") != null)
props.setProperty("Include patterns", System.getProperty("testPattern"))
props.store(fos, "Writing properties to output stream")
} catch (IOException e) {
logger.error(e.getMessage())
}
}
}
testClasses.finalizedBy beforeTest
test.finalizedBy afterTest