1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

编写测试用例

This commit is contained in:
2024-04-02 21:21:47 +08:00
parent 37c2442505
commit 4b046a7d14
6 changed files with 450 additions and 324 deletions

View File

@@ -3,8 +3,13 @@ import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
import testGroups from './test-case';
import { TestCase, TestCaseGroup } from '../type-definition/test-case-type';
import { transformText } from '../main-code/text-transform';
import { toCamelCase, toPascalCase } from '../main-code/text-conversion';
// import * as myExtension from '../../extension';
/*
suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');
@@ -13,3 +18,29 @@ suite('Extension Test Suite', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});
*/
suite('Extension Test: run test case', () => {
vscode.window.showInformationMessage('Start all tests.');
// transform to camel case
const groups: Array<TestCaseGroup> = testGroups;
for (const testGroup of groups) {
const testTitle = testGroup.testTitle;
const testCases: Array<TestCase> = testGroup.cases;
for (const testCase of testCases) {
test(testTitle + ' - ' + testCase.title, () => {
const inputList = Array.isArray(testCase.input) ? testCase.input : [testCase.input];
for (const input of inputList) {
// 验证 transformText
assert.strictEqual(testCase.transformText, transformText(input));
// 验证转换
assert.strictEqual(testCase.output.camelCase, toCamelCase(input));
assert.strictEqual(testCase.output.pascalCase, toPascalCase(input));
}
});
}
}
});