-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.js
158 lines (130 loc) · 5.78 KB
/
extension.js
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
const hx = require("hbuilderx");
const { about, checkUpgrade } = require('./public/about.js');
const { stopRunTest } = require('./src/lib/utils.js');
const Initialize = require('./src/Initialize.js');
const TestCaseCreate = require("./src/TestCaseCreate.js");
const { RunTest } = require("./src/TestCaseRun.js");
const openReportOutputDir = require('./src/TestReports.js');
function activate(context) {
// 检查升级
checkUpgrade();
let run = new RunTest();
// 初始化测试环境:安装测试环境、创建测试配置文件
let initialization = hx.commands.registerCommand('unitest.initialization', (param) => {
let init = new Initialize();
init.main(param);
});
context.subscriptions.push(initialization);
// 重装测试环境
let reloadEnv = hx.commands.registerCommand('unitest.reloadEnv', () => {
let init = new Initialize();
init.checkPluginDependencies(true);
});
context.subscriptions.push(reloadEnv);
// 创建测试用例 (uni-app项目,pages页面,右键菜单)
let createTestCase = hx.commands.registerCommand('unitest.createTestCase', (param) => {
TestCaseCreate(param);
});
context.subscriptions.push(createTestCase);
// 查看历史测试报告
let reportHistory = hx.commands.registerCommand('unitest.reportHistory', (param) => {
openReportOutputDir();
});
context.subscriptions.push(reportHistory);
// 运行所有测试用例:全部
let runTestAll = hx.commands.registerCommand('unitest.runTestAll', (param) => {
run.main(param, 'all');
});
context.subscriptions.push(runTestAll);
// 运行所有测试用例:H5-Chrome
let runTestH5 = hx.commands.registerCommand('unitest.runTestH5', (param) => {
run.main(param, 'h5');
});
context.subscriptions.push(runTestH5);
// 运行所有测试用例:H5-Firefox
let runTestH5Firefox = hx.commands.registerCommand('unitest.runTestH5Firefox', (param) => {
run.main(param, 'h5-firefox');
});
context.subscriptions.push(runTestH5Firefox);
// 运行所有测试用例:H5-Safari
let runTestH5Safari = hx.commands.registerCommand('unitest.runTestH5Safari', (param) => {
run.main(param, 'h5-safari');
});
context.subscriptions.push(runTestH5Safari);
// 运行所有测试用例:微信小程序
let runTestWeiXin = hx.commands.registerCommand('unitest.runTestWeiXin', (param) => {
run.main(param, 'mp-weixin');
});
context.subscriptions.push(runTestWeiXin);
// 运行所有测试用例:ios
let runTestIOS = hx.commands.registerCommand('unitest.runTestIOS', (param) => {
run.main(param, 'ios');
});
context.subscriptions.push(runTestIOS);
// 运行所有测试用例:android
let runTestAndroid = hx.commands.registerCommand('unitest.runTestAndroid', (param) => {
run.main(param, 'android');
});
context.subscriptions.push(runTestAndroid);
// 运行当前选择的测试用例:全部
let runCurrentTestToAll = hx.commands.registerCommand('unitest.runCurrentTestAll', (param) => {
run.main(param, 'all', 'one');
});
context.subscriptions.push(runCurrentTestToAll);
// 运行当前选择的测试用例:H5
let runCurrentTestToH5 = hx.commands.registerCommand('unitest.runCurrentTestH5', (param) => {
run.main(param, 'h5', 'one');
});
context.subscriptions.push(runCurrentTestToH5);
// 运行当前选择的测试用例:H5-Firefox
let runCurrentTestToH5Firefox = hx.commands.registerCommand('unitest.runCurrentTestH5Firefox', (param) => {
run.main(param, 'h5-firefox', 'one');
});
context.subscriptions.push(runCurrentTestToH5Firefox);
// 运行当前选择的测试用例:H5-Safari
let runCurrentTestToH5Safari = hx.commands.registerCommand('unitest.runCurrentTestH5Safari', (param) => {
run.main(param, 'h5-safari', 'one');
});
context.subscriptions.push(runCurrentTestToH5Safari);
// 运行当前选择的测试用例:微信小程序
let runCurrentTestToWeiXin = hx.commands.registerCommand('unitest.runCurrentTestWeiXin', (param) => {
run.main(param, 'mp-weixin', 'one');
});
context.subscriptions.push(runCurrentTestToWeiXin);
// 运行当前选择的测试用例:ios
let runCurrentTestToIOS = hx.commands.registerCommand('unitest.runCurrentTestIOS', (param) => {
run.main(param, 'ios', 'one');
});
context.subscriptions.push(runCurrentTestToIOS);
// 运行当前选择的测试用例:android
let runCurrentTestToAndroid = hx.commands.registerCommand('unitest.runCurrentTestAndroid', (param) => {
run.main(param, 'android', 'one');
});
context.subscriptions.push(runCurrentTestToAndroid);
// about
let aboutPlugins = hx.commands.registerCommand('unitest.about', () => {
about();
});
context.subscriptions.push(aboutPlugins);
// stop run
let stopRun = hx.commands.registerCommand('unitest.stopRunTest', () => {
stopRunTest();
});
context.subscriptions.push(stopRun);
let AutotestMatch = hx.commands.registerCommand('unitest.isAutotestMatch', () => {
let config = hx.workspace.getConfiguration();
let result = config.get('hbuilderx-for-uniapp-test.AutomaticModificationTestMatch');
config.update('hbuilderx-for-uniapp-test.AutomaticModificationTestMatch', !result).then( () => {
let text = result ? '取消' : '启用';
hx.window.setStatusBarMessage(`已 ${text} 自动修改testMatch。`, 'info', 10000);
});
});
context.subscriptions.push(AutotestMatch);
};
//该方法将在插件禁用的时候调用(目前是在插件卸载的时候触发)
function deactivate() {
}
module.exports = {
activate,
deactivate
}