forked from huilansame/HTMLTestRunner_PY3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleReport.html
543 lines (461 loc) · 15.7 KB
/
ExampleReport.html
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example用例执行报告</title>
<meta name="generator" content="HTMLTestRunner 0.9.1"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/echarts/3.8.5/echarts.common.min.js"></script>
<!-- <script type="text/javascript" src="js/echarts.common.min.js"></script> -->
<style type="text/css" media="screen">
body { font-family: Microsoft YaHei,Consolas,arial,sans-serif; font-size: 80%; }
table { font-size: 100%; }
pre { white-space: pre-wrap;word-wrap: break-word; }
/* -- heading ---------------------------------------------------------------------- */
h1 {
font-size: 16pt;
color: gray;
}
.heading {
margin-top: 0ex;
margin-bottom: 1ex;
}
.heading .attribute {
margin-top: 1ex;
margin-bottom: 0;
}
.heading .description {
margin-top: 2ex;
margin-bottom: 3ex;
}
/* -- css div popup ------------------------------------------------------------------------ */
a.popup_link {
}
a.popup_link:hover {
color: red;
}
.popup_window {
display: none;
position: relative;
left: 0px;
top: 0px;
/*border: solid #627173 1px; */
padding: 10px;
/*background-color: #E6E6D6; */
font-family: "Lucida Console", "Courier New", Courier, monospace;
text-align: left;
font-size: 8pt;
/* width: 500px;*/
}
}
/* -- report ------------------------------------------------------------------------ */
#show_detail_line {
margin-top: 3ex;
margin-bottom: 1ex;
}
#result_table {
width: 99%;
}
#header_row {
font-weight: bold;
color: #303641;
background-color: #ebebeb;
}
#total_row { font-weight: bold; }
.passClass { background-color: #bdedbc; }
.failClass { background-color: #ffefa4; }
.errorClass { background-color: #ffc9c9; }
.passCase { color: #6c6; }
.failCase { color: #FF6600; font-weight: bold; }
.errorCase { color: #c00; font-weight: bold; }
.hiddenRow { display: none; }
.testcase { margin-left: 2em; }
/* -- ending ---------------------------------------------------------------------- */
#ending {
}
#div_base {
position:absolute;
top:0%;
left:5%;
right:5%;
width: auto;
height: auto;
margin: -15px 0 0 0;
}
</style>
</head>
<body>
<script language="javascript" type="text/javascript"><!--
output_list = Array();
/* level - 0:Summary; 1:Failed; 2:All */
function showCase(level) {
trs = document.getElementsByTagName("tr");
for (var i = 0; i < trs.length; i++) {
tr = trs[i];
id = tr.id;
if (id.substr(0,2) == 'ft') {
if (level < 1) {
tr.className = 'hiddenRow';
}
else {
tr.className = '';
}
}
if (id.substr(0,2) == 'pt') {
if (level > 1) {
tr.className = '';
}
else {
tr.className = 'hiddenRow';
}
}
}
}
function showClassDetail(cid, count) {
var id_list = Array(count);
var toHide = 1;
for (var i = 0; i < count; i++) {
tid0 = 't' + cid.substr(1) + '.' + (i+1);
tid = 'f' + tid0;
tr = document.getElementById(tid);
if (!tr) {
tid = 'p' + tid0;
tr = document.getElementById(tid);
}
id_list[i] = tid;
if (tr.className) {
toHide = 0;
}
}
for (var i = 0; i < count; i++) {
tid = id_list[i];
if (toHide) {
document.getElementById('div_'+tid).style.display = 'none'
document.getElementById(tid).className = 'hiddenRow';
}
else {
document.getElementById(tid).className = '';
}
}
}
function showTestDetail(div_id){
var details_div = document.getElementById(div_id)
var displayState = details_div.style.display
// alert(displayState)
if (displayState != 'block' ) {
displayState = 'block'
details_div.style.display = 'block'
}
else {
details_div.style.display = 'none'
}
}
function html_escape(s) {
s = s.replace(/&/g,'&');
s = s.replace(/</g,'<');
s = s.replace(/>/g,'>');
return s;
}
/* obsoleted by detail in <div>
function showOutput(id, name) {
var w = window.open("", //url
name,
"resizable,scrollbars,status,width=800,height=450");
d = w.document;
d.write("<pre>");
d.write(html_escape(output_list[id]));
d.write("\n");
d.write("<a href='javascript:window.close()'>close</a>\n");
d.write("</pre>\n");
d.close();
}
*/
--></script>
<div id="div_base">
<div class='page-header'>
<h1>Example用例执行报告</h1>
<p class='attribute'><strong>开始时间:</strong> 2017-12-28 14:58:27</p>
<p class='attribute'><strong>运行时长:</strong> 0:00:00.003002</p>
<p class='attribute'><strong>状态:</strong> 通过 5 失败 4 错误 2</p>
</div>
<div style="float: left;width:50%;"><p class='description'>用于展示修改样式后的HTMLTestRunner</p></div>
<div id="chart" style="width:50%;height:400px;float:left;"></div>
<div class="btn-group btn-group-sm">
<button class="btn btn-default" onclick='javascript:showCase(0)'>总结</button>
<button class="btn btn-default" onclick='javascript:showCase(1)'>失败</button>
<button class="btn btn-default" onclick='javascript:showCase(2)'>全部</button>
</div>
<p></p>
<table id='result_table' class="table table-bordered">
<colgroup>
<col align='left' />
<col align='right' />
<col align='right' />
<col align='right' />
<col align='right' />
<col align='right' />
</colgroup>
<tr id='header_row'>
<td>测试套件/测试用例</td>
<td>总数</td>
<td>通过</td>
<td>失败</td>
<td>错误</td>
<td>查看</td>
</tr>
<tr class='errorClass'>
<td>TestTest: 测试HTMLTestRunner </td>
<td>7</td>
<td>3</td>
<td>3</td>
<td>1</td>
<td><a href="javascript:showClassDetail('c1',7)">详情</a></td>
</tr>
<tr id='pt1.1' class='hiddenRow'>
<td class='none'><div class='testcase'>test_a_divide_c: a / c = 1 这是个有subTest的用例</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_pt1.1')" >
通过</a>
<div id='div_pt1.1' class="popup_window">
<pre>pt1.1: a / c = 1
a / c = 1
a / c = 1
SubTestCase Pass:
test_a_divide_c (__main__.TestTest) (i=1)</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='ft1.2' class='none'>
<td class='failCase'><div class='testcase'>test_a_divide_c: a / c = 1 这是个有subTest的用例</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_ft1.2')" >
失败</a>
<div id='div_ft1.2' class="popup_window">
<pre>ft1.2: a / c = 1
a / c = 1
a / c = 1
SubTestCase Failed:
test_a_divide_c (__main__.TestTest) (i=2)Traceback (most recent call last):
File "E:/PY/HTMLTestRunner_PY3/test.py", line 32, in test_a_divide_c
self.assertEqual(self.a / i, 1)
AssertionError: 0.5 != 1
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='ft1.3' class='none'>
<td class='failCase'><div class='testcase'>test_a_divide_c: a / c = 1 这是个有subTest的用例</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_ft1.3')" >
失败</a>
<div id='div_ft1.3' class="popup_window">
<pre>ft1.3: a / c = 1
a / c = 1
a / c = 1
SubTestCase Failed:
test_a_divide_c (__main__.TestTest) (i=3)Traceback (most recent call last):
File "E:/PY/HTMLTestRunner_PY3/test.py", line 32, in test_a_divide_c
self.assertEqual(self.a / i, 1)
AssertionError: 0.3333333333333333 != 1
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='ft1.4' class='none'>
<td class='errorCase'><div class='testcase'>test_a_error_case: 除零异常</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_ft1.4')" >
错误</a>
<div id='div_ft1.4' class="popup_window">
<pre>ft1.4: 1/0
Traceback (most recent call last):
File "E:/PY/HTMLTestRunner_PY3/test.py", line 37, in test_a_error_case
self.assertEqual(self.a/0, 1)
ZeroDivisionError: division by zero
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='ft1.5' class='none'>
<td class='failCase'><div class='testcase'>test_a_minus_b: a - b = 3 这个用例应该失败</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_ft1.5')" >
失败</a>
<div id='div_ft1.5' class="popup_window">
<pre>ft1.5: a - b = 3
Traceback (most recent call last):
File "E:/PY/HTMLTestRunner_PY3/test.py", line 20, in test_a_minus_b
self.assertEqual(self.a-self.b, 3)
AssertionError: -1 != 3
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='pt1.6' class='hiddenRow'>
<td class='none'><div class='testcase'>test_a_multi_b: a * b = 2 这个用例应该成功</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_pt1.6')" >
通过</a>
<div id='div_pt1.6' class="popup_window">
<pre>pt1.6: a * b = 2
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='pt1.7' class='hiddenRow'>
<td class='none'><div class='testcase'>test_a_plus_b: a + b = 3 这个用例应该通过</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_pt1.7')" >
通过</a>
<div id='div_pt1.7' class="popup_window">
<pre>pt1.7: a + b = 3
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr class='failClass'>
<td>ExampleCase1: 此class包含两个用例:add - ok, minus - FAIL</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td><a href="javascript:showClassDetail('c2',2)">详情</a></td>
</tr>
<tr id='pt2.1' class='hiddenRow'>
<td class='none'><div class='testcase'>test_add: 用例1,add,此用例成功通过</div></td>
<td colspan='5' align='center'>通过</td>
</tr>
<tr id='ft2.2' class='none'>
<td class='failCase'><div class='testcase'>test_minus: 用例2,minus,此用例执行失败,4-3!=2</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_ft2.2')" >
失败</a>
<div id='div_ft2.2' class="popup_window">
<pre>ft2.2: 中文方法反反复复凤飞飞反复
Traceback (most recent call last):
File "E:/PY/HTMLTestRunner_PY3/test.py", line 53, in test_minus
self.assertEqual(self.a - self.b, 2)
AssertionError: 1 != 2
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr class='errorClass'>
<td>ExampleCase2: 此class包含一个用例:plus - ERROR</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td><a href="javascript:showClassDetail('c3',1)">详情</a></td>
</tr>
<tr id='ft3.1' class='none'>
<td class='errorCase'><div class='testcase'>test_plus: 用例3,plus,此用例执行出错,因为c未定义</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_ft3.1')" >
错误</a>
<div id='div_ft3.1' class="popup_window">
<pre>ft3.1: Traceback (most recent call last):
File "E:/PY/HTMLTestRunner_PY3/test.py", line 63, in test_plus
self.assertEqual(self.a * self.b, c)
NameError: name 'c' is not defined
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr class='passClass'>
<td>ExampleCase3: 此class包含一个用例:divide - ok</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td><a href="javascript:showClassDetail('c4',1)">详情</a></td>
</tr>
<tr id='pt4.1' class='hiddenRow'>
<td class='none'><div class='testcase'>test_devide: 用例4,divide,此用例执行成功</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_pt4.1')" >
通过</a>
<div id='div_pt4.1' class="popup_window">
<pre>pt4.1: 我要打印输出
我要打印输出222
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='total_row'>
<td>总计</td>
<td>11</td>
<td>5</td>
<td>4</td>
<td>2</td>
<td> </td>
</tr>
</table>
<div id='ending'> </div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('chart'));
// 指定图表的配置项和数据
var option = {
title : {
text: '测试执行情况',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
color: ['#95b75d', 'grey', '#b64645'],
legend: {
orient: 'vertical',
left: 'left',
data: ['通过','失败','错误']
},
series : [
{
name: '测试执行情况',
type: 'pie',
radius : '60%',
center: ['50%', '60%'],
data:[
{value:5, name:'通过'},
{value:4, name:'失败'},
{value:2, name:'错误'}
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</div>
</body>
</html>