Skip to content

Commit 6f7aa75

Browse files
authored
Add 2 E2E tests to verify the 'debug' and 'launch' modes are correctly configured (#117)
Objective Same as title. Abstractions Two test cases are added: when 'Debug: Attach' is selected, we start in attach mode when 'Debug: Launch' is selected, we start in launch mode Also updated package.json to uninstall AutolispExt after E2E tests are done, by adding "-u" opition. Tests performed The new added tests work as expected. Screen shot
1 parent 4164c7e commit 6f7aa75

File tree

2 files changed

+74
-25
lines changed

2 files changed

+74
-25
lines changed

extension/src/test/e2e/debugConfig.ts

Lines changed: 73 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,99 @@ import { expect } from 'chai';
22
import { InputBox, Workbench } from 'vscode-extension-tester';
33

44
describe('Debug Configuration Test', () => {
5-
let input: InputBox;
5+
let workbench: Workbench = null;
6+
let activeInput: InputBox = null;
7+
let debugStarted: boolean = false;
68

7-
const attachConfigText:string = 'AutoLISP Debug: Attach';
8-
const launchConfigText:string = 'AutoLISP Debug: Launch';
9-
const startDebugCmd:string = 'workbench.action.debug.start';
10-
11-
before(async () => {
12-
});
9+
const attachConfigText: string = 'AutoLISP Debug: Attach';
10+
const launchConfigText: string = 'AutoLISP Debug: Launch';
11+
12+
const startDebugCmd: string = 'workbench.action.debug.start';
13+
const stopDebugCmd: string = 'workbench.action.debug.stop';
1314

14-
after(async () => {
15-
await input.cancel();
16-
});
15+
const expectedAttachHint = 'Pick the process to attach.';
16+
const expectedLaunchHint = 'Specify the absolute path for the product.';
1717

18-
// to verify that the Attach and Launch config items show up when starting to debug via. VS Code
19-
it('should show debug config items on F5', async function() {
20-
this.timeout(15000);
18+
beforeEach(async () => {
19+
activeInput = null;
20+
debugStarted = false;
2121

22-
const workbench = new Workbench();
22+
workbench = new Workbench();
2323
await workbench.executeCommand(startDebugCmd);
24+
});
2425

25-
input = await InputBox.create();
26-
expect(await input.isDisplayed()).is.true;
26+
afterEach(async () => {
27+
if (activeInput) {
28+
if (await activeInput.isDisplayed())
29+
await activeInput.cancel();
30+
}
2731

28-
const picks = await input.getQuickPicks();
32+
if(debugStarted) {
33+
await workbench.executeCommand(stopDebugCmd);
34+
}
35+
});
2936

30-
const attachCfg:InputBox[] = await findAll(picks, async (x:InputBox) => { return attachConfigText === await x.getText();});
37+
// to verify that the config item named "Attach" is really for attach mode
38+
it('should show debug config items on F5', async function () {
39+
const cmdInput = await getActiveInputBox();
40+
expect(await cmdInput.isDisplayed()).is.true;
41+
42+
const picks = await cmdInput.getQuickPicks();
43+
44+
const attachCfg: InputBox[] = await findAll(picks, async (x: InputBox) => { return attachConfigText === await x.getText(); });
3145
expect(attachCfg.length).equals(1);
3246

33-
const launchCfg:InputBox[] = await findAll(picks, async (x:InputBox) => { return launchConfigText === await x.getText();});
47+
const launchCfg: InputBox[] = await findAll(picks, async (x: InputBox) => { return launchConfigText === await x.getText(); });
3448
expect(launchCfg.length).equals(1);
3549
});
3650

37-
async function findAll(array, callbackFind) : Promise<Array<InputBox>>{
38-
let ret:Array<InputBox> = [];
51+
// to verify that the "Attach" config item is bound to attach mode
52+
it('should debug in attach mode after selecting Debug: Attach', async function () {
53+
const cmdInput = await getActiveInputBox();
54+
expect(await cmdInput.isDisplayed()).is.true;
55+
56+
await cmdInput.setText(attachConfigText);
57+
await cmdInput.confirm();
58+
59+
debugStarted = true;
60+
61+
const procInput = await getActiveInputBox();
62+
expect((await procInput.getPlaceHolder()).startsWith(expectedAttachHint)).true;
63+
});
64+
65+
// to verify that the config item named "Launch" is really for launch mode
66+
it('should debug in launch mode after selecting Debug: Launch', async function () {
67+
const cmdInput = await getActiveInputBox();
68+
expect(await cmdInput.isDisplayed()).is.true;
69+
70+
await cmdInput.setText(launchConfigText);
71+
await cmdInput.confirm();
72+
73+
debugStarted = true;
74+
75+
const pathInput = await getActiveInputBox();
76+
expect((await pathInput.getPlaceHolder()).startsWith(expectedLaunchHint)).true;
77+
});
3978

40-
for(const item of array) {
79+
async function findAll(array, callbackFind): Promise<Array<InputBox>> {
80+
let ret: Array<InputBox> = [];
81+
82+
for (const item of array) {
4183
const matched: boolean = await callbackFind(item);
42-
if(!matched)
84+
if (!matched)
4385
continue;
44-
86+
4587
ret.push(item);
4688
}
4789

4890
return ret;
4991
}
5092

93+
async function getActiveInputBox(): Promise<InputBox> {
94+
let input = await InputBox.create();
95+
activeInput = input;
96+
97+
return activeInput;
98+
}
99+
51100
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@
617617
"watch": "tsc -p -watch ./",
618618
"test": "npm run compile && node ./out/test/runTest.js",
619619
"cc": "npm run compile && node ./out/test/runTest.js --codecoverage",
620-
"e2etest": "npm run compile && extest setup-and-run -c 1.50.0 ./out/test/e2e/*.js -m ./out/test/e2e/config.js"
620+
"e2etest": "npm run compile && extest setup-and-run -c 1.50.0 ./out/test/e2e/*.js -m ./out/test/e2e/config.js -u"
621621
},
622622
"devDependencies": {
623623
"@istanbuljs/nyc-config-typescript": "^1.0.1",

0 commit comments

Comments
 (0)