-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
188 lines (180 loc) · 8.74 KB
/
build.gradle
File metadata and controls
188 lines (180 loc) · 8.74 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import groovy.xml.MarkupBuilder
plugins {
id 'base'
}
group 'gradleReporterDemo'
version '1.0-SNAPSHOT'
def buildDirExist() {
File buildDir = file("${project.buildDir}")
if (!buildDir.exists()) {
buildDir.mkdirs()
}
copy {
from "${project.projectDir}/css"
into "${project.buildDir}/css"
}
}
task htmlReport {
doFirst {
buildDirExist()
}
doLast {
def xmlFile = new XmlParser().parse(new File("demo.xml"))
def xmlWriter = new FileWriter(file("${project.buildDir}/index.html"))
def xmlMarkup = new MarkupBuilder(xmlWriter)
xmlWriter.write("<!DOCTYPE html>\n")
xmlMarkup.html() {
head() {
meta(charset: "utf-8")
meta(name: "viewport", content:"width=device-width, initial-scale=1, maximum-scale=1")
title("Test Report")
link(rel: "stylesheet", href: "./css/main.css") { mkp.yield("") }
link(rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css", media: "screen,projection") { mkp.yield("") }
link(rel: "stylesheet", href: "https://fonts.googleapis.com/icon?family=Material+Icons") { mkp.yield("") }
}
body(){
header(){
div("class":"nav-wrapper"){
nav(class: "blue darken-3") {
a(class: "brand-logo", href: "#",id: "logo-container") {
img(class: "logo-img",src: "") {
mkp.yield("")
}
}
a("href":"index.html") {
ul(class: "center flow-text", "TEST RESULTS")
}
}
}
}
main() {
div(class: "container") {
div(style: "margin-bottom: 50px;") {
table(class: "striped responsive-table", id: "example") {
thead() {
tr() {
th(class: "center","Test Suite")
th(class: "center","Passed")
th(class: "center","Failed")
th(class: "center","Total")
}
}
tbody() {
xmlFile.testsuite.each { testsuite ->
tr() {
td(class: "center",) {
a(href: "report.html",testsuite['@name'])
}
td(class: "center",Integer.valueOf(Integer.valueOf(testsuite['@tests']) - Integer.valueOf(testsuite['@failure'])))
td(class: "center",testsuite['@failure'])
td(class: "center",testsuite['@tests'])
}
}
}
}
}
}
}
}
footer(class: "page-footer blue darken-3") {
div(class: "footer-copyright") {
div(class: "container", "Demo By - rookieInTraining") {
a(class: "grey-text text-lighten-4 right", "")
}
}
}
script(type: "text/javascript", src: "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js") { mkp.yield("") }
}
}
}
task resultGenerator() {
doFirst {
buildDirExist()
}
doLast {
def xmlFile = new XmlParser().parse(new File("demo.xml"))
def xmlWriter = new FileWriter(file("${project.buildDir}/report.html"))
def xmlMarkup = new MarkupBuilder(xmlWriter)
xmlWriter.write("<!DOCTYPE html>\n")
xmlMarkup.html() {
head() {
meta(charset: "utf-8")
meta(name: "viewport", content:"width=device-width, initial-scale=1, maximum-scale=1")
title("Test Report")
link(rel: "stylesheet", href: "./css/main.css") { mkp.yield("") }
link(rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css", media: "screen,projection") { mkp.yield("") }
link(rel: "stylesheet", href: "https://fonts.googleapis.com/icon?family=Material+Icons") { mkp.yield("") }
}
body(){
header(){
div("class":"nav-wrapper"){
nav(class: "blue darken-3") {
a(class: "brand-logo", href: "#",id: "logo-container") {
img(class: "logo-img",src: "") {
mkp.yield("")
}
}
a("href":"index.html") {
ul(class: "center flow-text", "TEST RESULTS")
}
}
}
}
main() {
div("class":"container") {
xmlFile.testsuite.each { testsuite ->
h2("Suite Name : " + testsuite['@name'])
h5("Total Tests Executed : " + testsuite['@tests'])
h5("Total Tests Failed : " + testsuite['@failure'])
h5("Date : " + testsuite['@timestamp'])
div(style: "margin-bottom: 50px;") {
table(class: "striped highlight responsive-table") {
thead() {
tr() {
th(class: "center","Test Name")
th(class: "center","Result")
th(class: "center","Failure Reason")
th(class: "center","Test URL")
}
}
tbody() {
testsuite.testcase.each { testcase ->
if(testcase.failure.size() <= 0) {
tr(class: "green lighten-5") {
td(class: "center",testcase['@name'])
td(class: "center","Passed")
td("")
td(class: "center") {
a(href: "#", testcase.'system-out'.text())
}
}
} else {
tr(class: "red lighten-5") {
td(class: "center",testcase['@name'])
td(class: "center", "Failed")
td(class: "center", testcase.failure['@message'].toString().replace("[","").replace("]","").split("More info")[0])
td(class: "center") {
a(href: "#", testcase.'system-out'.text())
}
}
}
}
}
}
}
}
}
}
}
footer(class: "page-footer blue darken-3") {
div(class: "footer-copyright") {
div(class: "container", "Demo By - rookieInTraining") {
a(class: "grey-text text-lighten-4 right", "")
}
}
}
script(type: "text/javascript", src: "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js") { mkp.yield("") }
}
}
}
resultGenerator.dependsOn htmlReport