|
130 | 130 | history: {name: '请求0'},
|
131 | 131 | remotes: [],
|
132 | 132 | tests: [],
|
| 133 | + testProcess: '', |
133 | 134 | isDelayShow: false,
|
134 | 135 | isSaveShow: false,
|
135 | 136 | isExportShow: false,
|
|
1181 | 1182 | 4-类型改变,红色;
|
1182 | 1183 | */
|
1183 | 1184 | 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) { |
1186 | 1189 | alert('请先获取测试用例文档\n点击[查看共享]图标按钮')
|
1187 | 1190 | return
|
1188 | 1191 | }
|
1189 | 1192 | var baseUrl = App.getBaseUrl()
|
1190 |
| - var item |
1191 | 1193 | for (var i = 0; i < list.length; i ++) {
|
1192 |
| - item = list[i] |
| 1194 | + const item = list[i] |
1193 | 1195 | if (item == null || item.name == null) {
|
1194 | 1196 | continue
|
1195 | 1197 | }
|
1196 |
| - if (item.userId != App.User.id || item.url == '/logout') { |
| 1198 | + if (item.url == '/logout') {// || item.userId != App.User.id) { |
1197 | 1199 | console.log('test item.userId != User.id || item.url == /logout >> continue')
|
1198 | 1200 | continue
|
1199 | 1201 | }
|
1200 | 1202 | console.log('test item = ' + JSON.stringify(item, null, ' '))
|
1201 | 1203 |
|
1202 |
| - App.restore(item) |
1203 |
| - App.onChange(false) |
| 1204 | + // App.restore(item) |
| 1205 | + // App.onChange(false) |
1204 | 1206 |
|
1205 | 1207 | const index = i; //请求异步
|
1206 | 1208 | 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 || {}) |
1211 | 1217 |
|
1212 |
| - var it = list[index] //请求异步 |
| 1218 | + var it = item || {} //请求异步 |
1213 | 1219 | it.compare = it.response == response ? 0 : 4
|
1214 | 1220 | 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 |
1221 | 1229 |
|
1222 | 1230 | var tests = App.tests || {}
|
1223 | 1231 | tests[it.id] = response
|
1224 | 1232 | App.tests = tests
|
1225 |
| - App.isRemoteShow = true |
| 1233 | + // App.showRemote(true) |
| 1234 | + |
1226 | 1235 | })
|
1227 | 1236 | }
|
1228 | 1237 | },
|
|
0 commit comments