Skip to content

Commit

Permalink
Add 2 E2E tests to verify the 'debug' and 'launch' modes are correctl…
Browse files Browse the repository at this point in the history
…y 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
  • Loading branch information
Sen-real authored Apr 6, 2021
1 parent 4164c7e commit 6f7aa75
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 25 deletions.
97 changes: 73 additions & 24 deletions extension/src/test/e2e/debugConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,99 @@ import { expect } from 'chai';
import { InputBox, Workbench } from 'vscode-extension-tester';

describe('Debug Configuration Test', () => {
let input: InputBox;
let workbench: Workbench = null;
let activeInput: InputBox = null;
let debugStarted: boolean = false;

const attachConfigText:string = 'AutoLISP Debug: Attach';
const launchConfigText:string = 'AutoLISP Debug: Launch';
const startDebugCmd:string = 'workbench.action.debug.start';

before(async () => {
});
const attachConfigText: string = 'AutoLISP Debug: Attach';
const launchConfigText: string = 'AutoLISP Debug: Launch';

const startDebugCmd: string = 'workbench.action.debug.start';
const stopDebugCmd: string = 'workbench.action.debug.stop';

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

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

const workbench = new Workbench();
workbench = new Workbench();
await workbench.executeCommand(startDebugCmd);
});

input = await InputBox.create();
expect(await input.isDisplayed()).is.true;
afterEach(async () => {
if (activeInput) {
if (await activeInput.isDisplayed())
await activeInput.cancel();
}

const picks = await input.getQuickPicks();
if(debugStarted) {
await workbench.executeCommand(stopDebugCmd);
}
});

const attachCfg:InputBox[] = await findAll(picks, async (x:InputBox) => { return attachConfigText === await x.getText();});
// to verify that the config item named "Attach" is really for attach mode
it('should show debug config items on F5', async function () {
const cmdInput = await getActiveInputBox();
expect(await cmdInput.isDisplayed()).is.true;

const picks = await cmdInput.getQuickPicks();

const attachCfg: InputBox[] = await findAll(picks, async (x: InputBox) => { return attachConfigText === await x.getText(); });
expect(attachCfg.length).equals(1);

const launchCfg:InputBox[] = await findAll(picks, async (x:InputBox) => { return launchConfigText === await x.getText();});
const launchCfg: InputBox[] = await findAll(picks, async (x: InputBox) => { return launchConfigText === await x.getText(); });
expect(launchCfg.length).equals(1);
});

async function findAll(array, callbackFind) : Promise<Array<InputBox>>{
let ret:Array<InputBox> = [];
// to verify that the "Attach" config item is bound to attach mode
it('should debug in attach mode after selecting Debug: Attach', async function () {
const cmdInput = await getActiveInputBox();
expect(await cmdInput.isDisplayed()).is.true;

await cmdInput.setText(attachConfigText);
await cmdInput.confirm();

debugStarted = true;

const procInput = await getActiveInputBox();
expect((await procInput.getPlaceHolder()).startsWith(expectedAttachHint)).true;
});

// to verify that the config item named "Launch" is really for launch mode
it('should debug in launch mode after selecting Debug: Launch', async function () {
const cmdInput = await getActiveInputBox();
expect(await cmdInput.isDisplayed()).is.true;

await cmdInput.setText(launchConfigText);
await cmdInput.confirm();

debugStarted = true;

const pathInput = await getActiveInputBox();
expect((await pathInput.getPlaceHolder()).startsWith(expectedLaunchHint)).true;
});

for(const item of array) {
async function findAll(array, callbackFind): Promise<Array<InputBox>> {
let ret: Array<InputBox> = [];

for (const item of array) {
const matched: boolean = await callbackFind(item);
if(!matched)
if (!matched)
continue;

ret.push(item);
}

return ret;
}

async function getActiveInputBox(): Promise<InputBox> {
let input = await InputBox.create();
activeInput = input;

return activeInput;
}

});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@
"watch": "tsc -p -watch ./",
"test": "npm run compile && node ./out/test/runTest.js",
"cc": "npm run compile && node ./out/test/runTest.js --codecoverage",
"e2etest": "npm run compile && extest setup-and-run -c 1.50.0 ./out/test/e2e/*.js -m ./out/test/e2e/config.js"
"e2etest": "npm run compile && extest setup-and-run -c 1.50.0 ./out/test/e2e/*.js -m ./out/test/e2e/config.js -u"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
Expand Down

0 comments on commit 6f7aa75

Please sign in to comment.