Skip to content

Commit cbf1252

Browse files
committed
新增测试进度;优化测试时的显示
1 parent f2b4307 commit cbf1252

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<use xlink:href="svg/icon.svg#share"></use>
8787
</svg>
8888
<span style="display: flex;flex-grow: 1;font-size: medium;margin-left: 6px">测试用例</span>
89+
<a >{{ testProcess }}</a>
8990
<a class="hint--top save-tool" data-hint="回归测试" href="javascript:void(0)" @click="test()">
9091
<img class="icon" src="img/refresh.png"/>
9192
</a>

js/main.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
history: {name: '请求0'},
131131
remotes: [],
132132
tests: [],
133+
testProcess: '',
133134
isDelayShow: false,
134135
isSaveShow: false,
135136
isExportShow: false,
@@ -1181,48 +1182,56 @@
11811182
4-类型改变,红色;
11821183
*/
11831184
test: function () {
1184-
var list = App.remotes || []
1185-
if (list.length <= 0) {
1185+
const list = App.remotes || []
1186+
const allCount = list.length - 1
1187+
App.testProcess = allCount <= 0 ? '' : '正在测试: ' + 0 + '/' + allCount
1188+
if (allCount <= 0) {
11861189
alert('请先获取测试用例文档\n点击[查看共享]图标按钮')
11871190
return
11881191
}
11891192
var baseUrl = App.getBaseUrl()
1190-
var item
11911193
for (var i = 0; i < list.length; i ++) {
1192-
item = list[i]
1194+
const item = list[i]
11931195
if (item == null || item.name == null) {
11941196
continue
11951197
}
1196-
if (item.userId != App.User.id || item.url == '/logout') {
1198+
if (item.url == '/logout') {// || item.userId != App.User.id) {
11971199
console.log('test item.userId != User.id || item.url == /logout >> continue')
11981200
continue
11991201
}
12001202
console.log('test item = ' + JSON.stringify(item, null, ' '))
12011203

1202-
App.restore(item)
1203-
App.onChange(false)
1204+
// App.restore(item)
1205+
// App.onChange(false)
12041206

12051207
const index = i; //请求异步
12061208
App.request(baseUrl + item.url, JSON.parse(item.request), function (url, res, err) {
1207-
App.onResponse(url, res, err)
1208-
console.log('test App.request >> res.data = ' + JSON.stringify(res.data, null, ' '))
1209-
1210-
var response = JSON.stringify(res.data)
1209+
var response = ''
1210+
try {
1211+
App.onResponse(url, res, err)
1212+
console.log('test App.request >> res.data = ' + JSON.stringify(res.data, null, ' '))
1213+
} catch (e) {
1214+
console.log('test App.request >> } catch (e) {\n' + e.message)
1215+
}
1216+
response = JSON.stringify(res.data || {})
12111217

1212-
var it = list[index] //请求异步
1218+
var it = item || {} //请求异步
12131219
it.compare = it.response == response ? 0 : 4
12141220
console.log('i = ' + index + '; item.name = ' + it.name + '; item.compare = ' + it.compare)
1215-
if (it.compare > 0) {
1216-
alert('i = ' + index + '; item.name = ' + it.name + '; item.compare = ' + it.compare
1217-
+ '; it.response = \n' + it.response
1218-
+ '\n\n\n res.data = \n' + response
1219-
)
1220-
}
1221+
// if (it.compare > 0) {
1222+
// alert('i = ' + index + '; item.name = ' + it.name + '; item.compare = ' + it.compare
1223+
// + '; it.response = \n' + it.response
1224+
// + '\n\n\n res.data = \n' + response
1225+
// )
1226+
// }
1227+
1228+
App.testProcess = index <= allCount ? '' : '正在测试: ' + index + '/' + allCount
12211229

12221230
var tests = App.tests || {}
12231231
tests[it.id] = response
12241232
App.tests = tests
1225-
App.isRemoteShow = true
1233+
// App.showRemote(true)
1234+
12261235
})
12271236
}
12281237
},

0 commit comments

Comments
 (0)