-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle
151 lines (120 loc) · 5.4 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
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
145
146
147
148
149
150
151
plugins {
id 'java'
id 'idea'
}
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/junit/junit
implementation group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/de.monochromata.cucumber/reporting-plugin
implementation group: 'de.monochromata.cucumber', name: 'reporting-plugin', version: '3.0.7'
// https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm
implementation group: 'io.cucumber', name: 'cucumber-jvm', version: '4.7.4', ext: 'pom'
// https://mvnrepository.com/artifact/org.apache.commons/commons-text
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.8'
// https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2
implementation group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.7.0'
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.1'
// https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager
implementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '3.7.1'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server
implementation group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '4.0.0-alpha-1'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12
testImplementation group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.29'
// https://mvnrepository.com/artifact/org.assertj/assertj-core
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.13.2'
// https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer
testImplementation group: 'io.cucumber', name: 'cucumber-picocontainer', version: '4.7.4'
// needed for run time on tests but is included within cucumber-jvm
testImplementation 'io.cucumber:cucumber-java:4.7.4'
testImplementation 'io.cucumber:cucumber-junit:4.7.4'
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
////////////////////////////////////////////////////////////////////////////////
// Cucumber tasks and variables to set tag expressions and env before running //
////////////////////////////////////////////////////////////////////////////////
def cucumberOptions = ['-p', 'pretty',
'--add-plugin', 'de.monochromata.cucumber.report.PrettyReports:TestResults/Reports/cucumber-html',
'-p', 'json:TestResults/Reports/cucumber-report.json',
'-g', 'gradle.cucumber',
'-g', 'core.setup',
'-g', 'core.test.steps',
'src/test/resources',]
def cucumberTagExpression = ['-t', '@Web']
def availableThreadCount = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
def cucumberThreadsOption = ['--threads', availableThreadCount.toString()]
def setParallel = "false"
def setEnv = '\"https://gfycat.com/\"'
/**
* Task that runs cucumber with given cucumber.options
*
* Example Command Line for test run:
* gradlew clean build cucumber giphyEnv neatGifTest cucumber
*
*/
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
systemProperty "env", System.properties.getProperty("env", setEnv)
systemProperty "parallel", System.properties.getProperty("parallel", setParallel)
systemProperties(System.properties as Map<String, ?>)
cucumberOptions.addAll(cucumberTagExpression)
if (setParallel == "true") cucumberOptions.addAll(cucumberThreadsOption)
args = cucumberOptions
}
}
}
/**
* runs the build in parallel if used
*/
task runInParallel() {
group = 'Cucumber Parallel'
description = 'Runs build in parallel if used'
doLast {
setParallel = "true"
}
}
///////////////////////////////////////////////////////
// Tasks to set tag expressions before cucumber task //
///////////////////////////////////////////////////////
//<editor-fold desc="Tag Expressions">
task neatGifTest() {
group = 'Cucumber TagExpressions'
description = 'Sets @NeatGifTest tests to be ran'
doLast {
cucumberTagExpression = ['-t', '@NeatGifTest']
}
}
task gradleCommandLineExample() {
group = 'Cucumber Help'
description = '''Command Line Examples
-> [ENV] and [CucumberTagExpressions] tasks must be called before task [cucumber] !!!
-> gradlew clean build [ENV] [CucumberTagExpressions] cucumber
*Example: gradlew clean build giphyEnv neatGifTest cucumber
*Example Remote: gradlew clean build giphyEnv neatGifTest cucumber -DisRemote="true"
*Parallel Example: gradlew clean build runInParallel giphyEnv neatGifTest cucumber"'''
}
//</editor-fold>
///////////////////////////////////////////
// Tasks to set env before cucumber task //
///////////////////////////////////////////
//<editor-fold desc="Env's">
task giphyEnv() {
group = 'Cucumber ENV'
description = 'Sets ENV to giphy'
doLast { setEnv = '\"https://gfycat.com/\"' }
}
//</editor-fold>