Skip to content

Commit d1652e3

Browse files
committed
Prepare for release
1 parent ff2b6a0 commit d1652e3

File tree

9 files changed

+51
-32
lines changed

9 files changed

+51
-32
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.0.0 (23-Jul-2025)
2+
* Use [Test Coverage Tool](https://openexchange.intersystems.com/package/Test-Coverage-Tool) to present coverage information (#24)
3+
14
## 0.2.3 (13-Nov-2024)
25
* Add manual refresh to test trees, and automatic refresh when client setting changes (#20)
36
* Fix overprompting during authentication.

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# InterSystems Testing Manager
22

3-
This preview extension uses VS Code's [Testing API](https://code.visualstudio.com/api/extension-guides/testing) to discover, run and debug unit test classes built with the [%UnitTest testing framework](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=TUNT_WhatIsPercentUnitTest) of the InterSystems IRIS platforms, plus Caché-based predecessors supporting the `/api/atelier` REST service.
3+
> **New in Version 2.0 - Test Coverage**
4+
>
5+
> The v2.0 release has been entered into the [InterSystems Developer Tools Contest 2025](https://openexchange.intersystems.com/contest/42). Please support it with your vote between 28th July and 3rd August.
6+
7+
This extension uses VS Code's [Testing API](https://code.visualstudio.com/api/extension-guides/testing) to discover, run and debug unit test classes built with the [%UnitTest testing framework](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=TUNT_WhatIsPercentUnitTest) of the InterSystems IRIS platforms, plus Caché-based predecessors supporting the `/api/atelier` REST service.
48

59
It augments the ObjectScript, InterSystems Language Server and Server Manager extensions, which are elements of the [InterSystems ObjectScript Extension Pack](https://marketplace.visualstudio.com/items?itemName=intersystems-community.objectscript-pack).
610

@@ -34,6 +38,8 @@ In order to support topologies in which client-side-managed test classes have to
3438
```
3539
> If you previously used the `%UnitTest` framework in a namespace, be aware that you are probably replacing an existing value. Consider taking a note of that in case you need to revert.
3640
41+
3. If you want to gather and display test coverage data, set up [Test Coverage Tool](https://openexchange.intersystems.com/package/Test-Coverage-Tool) in the namespace(s) where your tests will execute.
42+
3743
## Workspace Preparations
3844
3945
For a workspace using client-side editing, test classes are by default sought in `.cls` files under the `internal/testing/unit_tests` subfolder, using the conventional layout of one additional subfolder per package-name element. If your test classes are located elsewhere, use the `intersystems.testingManager.client.relativeTestRoot` setting to point there.
@@ -50,7 +56,7 @@ A subfolder is shown for each root folder of your workspace, which may be a mult
5056
5157
At the level of an individual test class the final expansion shows a leaf for each `TestXXX` method.
5258
53-
Hovering over any level of a tests tree will reveal action buttons that run all the tests from this level down. The 'Run' button does so without stopping at any breakpoints, in contrast to the 'Debug' button. At class or method level a 'Go to Test' button opens the class code and positions the cursor appropriately. At higher levels this button navigates to Explorer View.
59+
Hovering over any level of a tests tree will reveal action buttons that run all the tests from this level down. The 'Run Test' button does so without stopping at any breakpoints, in contrast to the 'Debug Test' button. At class or method level a 'Go to Test' button opens the class code and positions the cursor appropriately. At higher levels this button navigates to Explorer View.
5460
5561
When a test class is open in an editor tab it displays icons in the gutter at the top of the class and at the start of each test method. These show the outcome of the most recent run, if any, and can be clicked to perform testing operations.
5662
@@ -59,6 +65,9 @@ The `...` menu of the Testing panel in Test Explorer includes several useful com
5965
## Debugging Tests
6066
After opening a test class, click in the gutter to set a VS Code breakpoint in the normal manner. Then launch the test-run with the Debug option on the context menu of the testing icons in the gutter.
6167
68+
## Obtaining Test Coverage Information
69+
Use the 'Run with Coverage' option to submit your tests to [Test Coverage Tool](https://openexchange.intersystems.com/package/Test-Coverage-Tool). When the run finishes the 'TEST COVERAGE' view will appear, usually below the 'TEST EXPLORER'. Use this to discover what proportion of executable code lines were covered by the most recent coverage run. Open sources to see color markers on line numbers showing covered (green) and not covered (red) lines. Learn more in the [VS Code documentation](https://code.visualstudio.com/docs/debugtest/testing#_test-coverage).
70+
6271
## Recent Testing History
6372
6473
The %UnitTest framework persists results of runs in server-side tables. The 'Recent History' root folder lets you explore the most recent ten sets of results for each server and namespace the workspace uses.

package-lock.json

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "testingmanager",
33
"displayName": "InterSystems Testing Manager",
4-
"version": "0.2.4-SNAPSHOT",
4+
"version": "2.0.0-SNAPSHOT",
55
"preview": true,
66
"publisher": "intersystems-community",
77
"description": "Manage testing on InterSystems servers.",

src/commonRunTestsHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
3636

3737
if (coverageRequest && !queue.length) {
3838
// No tests to run, but coverage requested
39-
vscode.window.showErrorMessage("Coverage support not available on target environment(s).", { modal: true });
39+
vscode.window.showErrorMessage("[Test Coverage Tool](https://openexchange.intersystems.com/package/Test-Coverage-Tool) not found.", );
4040
return;
4141
}
4242

src/historyExplorer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export function replaceRootItems(controller: vscode.TestController, schemes?: st
285285
if (!rootMap.has(key)) {
286286
const item: OurTestItem = controller.createTestItem(key, key, folder.uri);
287287
item.canResolveChildren = true;
288-
item.supportsCoverage = true; // TODO - check target namespace supports coverage
288+
item.supportsCoverage = false;
289289
rootMap.set(key, item);
290290
}
291291
}

src/localTests.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,7 @@ async function resolveItemChildren(item: OurTestItem) {
7575
if (localTestController.items.size > 0) {
7676
localTestController.createRunProfile('Run Local Tests', vscode.TestRunProfileKind.Run, runTestsHandler, true);
7777
localTestController.createRunProfile('Debug Local Tests', vscode.TestRunProfileKind.Debug, runTestsHandler);
78-
let supportsCoverage = false;
79-
localTestController.items.forEach((item: OurTestItem) => {
80-
if (item.supportsCoverage) {
81-
supportsCoverage = true;
82-
};
83-
});
84-
if (supportsCoverage) {
85-
localTestController.createRunProfile('Run Local Tests with Coverage', vscode.TestRunProfileKind.Coverage, runTestsHandler);
86-
}
78+
localTestController.createRunProfile('Run Local Tests with Coverage', vscode.TestRunProfileKind.Coverage, runTestsHandler);
8779
}
8880
}
8981
}

src/ourFileCoverage.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,27 @@ export class OurFileCoverage extends vscode.FileCoverage {
9393
serverSpec,
9494
{ apiVersion: 1, namespace, path: "/action/query" },
9595
{
96-
query: "SELECT element_key Line, LineToMethodMap Method FROM TestCoverage_Data.CodeUnit_LineToMethodMap WHERE CodeUnit = ? ORDER BY Line",
96+
query: "SELECT element_key StartLine, LineToMethodMap Method FROM TestCoverage_Data.CodeUnit_LineToMethodMap WHERE CodeUnit = ? ORDER BY StartLine",
9797
parameters: [this.codeUnit],
9898
},
9999
);
100100
if (response) {
101+
let previousMethod = "";
102+
let previousStartLine = 0;
101103
response?.data?.result?.content?.forEach(element => {
102-
logger.debug(`getFileCoverageResults element: ${JSON.stringify(element)}`);
103-
if (element.Executable == '0') {
104-
logger.debug(`Skipping non-executable line: ${JSON.stringify(element)}`);
105-
return;
104+
if (previousMethod && previousStartLine) {
105+
const start = new vscode.Position(Number(previousStartLine) - 1, 0);
106+
const end = new vscode.Position(Number(element.StartLine) - 2, Number.MAX_VALUE);
107+
detailedCoverage.push(new vscode.DeclarationCoverage(previousMethod, true, new vscode.Range(start, end)));
106108
}
107-
const range = new vscode.Range(new vscode.Position(Number(element.LineNumber) - 1, 0), new vscode.Position(Number(element.LineNumber) - 1, Number.MAX_VALUE));
108-
const statementCoverage = new vscode.StatementCoverage(element.Covered == '1', range);
109-
//detailedCoverage.push(statementCoverage);
109+
previousMethod = element.Method;
110+
previousStartLine = Number(element.StartLine);
110111
});
112+
if (previousMethod && previousStartLine) {
113+
const start = new vscode.Position(Number(previousStartLine) - 1, 0);
114+
const end = new vscode.Position(Number.MAX_VALUE, Number.MAX_VALUE);
115+
detailedCoverage.push(new vscode.DeclarationCoverage(previousMethod, true, new vscode.Range(start, end)));
116+
}
111117
}
112118
return detailedCoverage;
113119
}

src/utils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,22 @@ export async function supportsCoverage(folder: vscode.WorkspaceFolder): Promise<
3636
return false; // No server spec means we can't check coverage support
3737
}
3838
logger.debug(`Checking coverage support for namespace: ${namespace}`);
39-
const response = await makeRESTRequest(
39+
let response = await makeRESTRequest(
4040
"HEAD",
4141
serverSpec,
4242
{ apiVersion: 1, namespace, path: "/doc/TestCoverage.Data.CodeUnit.cls" }
4343
);
4444
if (response?.status !== 200) {
4545
return false;
4646
}
47+
response = await makeRESTRequest(
48+
"HEAD",
49+
serverSpec,
50+
{ apiVersion: 1, namespace, path: "/doc/TestCoverage.UI.VSCodeUtils.cls" }
51+
);
52+
if (response?.status === 200) {
53+
return true;
54+
}
4755

4856
return await createSQLUtilFunctions(serverSpec, namespace);
4957
}
@@ -52,7 +60,7 @@ async function createSQLUtilFunctions(serverSpec: IServerSpec, namespace: string
5260
logger.debug(`Creating SQL Util functions for namespace: ${namespace}`);
5361

5462
const functionDDL = `
55-
CREATE OR REPLACE FUNCTION fnVSCodeInt8Bitstring(
63+
CREATE FUNCTION fnVSCodeInt8Bitstring(
5664
bitstring VARCHAR(32767)
5765
)
5866
FOR TestCoverage.UI.VSCodeUtils

0 commit comments

Comments
 (0)