Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement basic Text Explorer support for scalatest #1117

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"properties": {
"metals.serverVersion": {
"type": "string",
"default": "0.11.8+25-04b682be-SNAPSHOT",
"default": "0.11.8+38-1832a3cf-SNAPSHOT",
"markdownDescription": "The version of the Metals server artifact. Requires reloading the window. \n\n**VS Code extension version is guaranteed to work only with the default version, change if you know what you're doing**"
},
"metals.serverProperties": {
Expand Down
20 changes: 16 additions & 4 deletions src/testExplorer/analyzeTestRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function analyzeTestRun(
if (result != null) {
// if suite run contains test cases (run was started for (single) test case)
if (kind === "testcase") {
analyzeTestCases(run, result, [test]);
analyzeTestCases(run, result, [test], test.parent);
}
// if test suite has children (test cases) do a more fine-grained analyze of results.
// run was started for whole suite which has children (e.g. junit one)
Expand Down Expand Up @@ -76,7 +76,8 @@ function analyzeTestCases(
testCases: vscode.TestItem[],
parent?: vscode.TestItem
) {
const testCasesResults = createTestCasesMap(result);
const parentName = parent?.id || "";
const testCasesResults = createTestCasesMap(result, parentName);
testCases.forEach((test) => {
const name = test.id as TestName;
const testCaseResult = testCasesResults.get(name);
Expand Down Expand Up @@ -105,12 +106,23 @@ function analyzeTestCases(

/**
* Transforms suite result into mapping between test case name and its result.
*
* @param parentName test cases are prefixed with parent (suite) name.
* However, some test frameworks like scalatest send results which are not prefixed, other like munit send prefixed results, etc.
* To unify handling, make sure that all results starts with given parentName.
*/
function createTestCasesMap(
testSuiteResult: TestSuiteResult
testSuiteResult: TestSuiteResult,
parentName: string
): Map<TestName, SingleTestResult> {
const tuples: [TestName, SingleTestResult][] = testSuiteResult.tests.map(
(test) => [test.testName, test]
(test) => {
const name = test.testName.startsWith(parentName)
? test.testName
: `${parentName}.${test.testName}`;

return [name as TestName, test];
}
);
const testCasesResult = new Map(tuples);
return testCasesResult;
Expand Down