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

fix - Catch the error when running gradle tests #1524

Merged
merged 1 commit into from
Jul 22, 2024
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
24 changes: 14 additions & 10 deletions extension/src/bs/GradleTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
private readonly _onDidChangeTestItemStatus = new vscode.EventEmitter<TestItemStatusChangeEvent>();
private readonly _onDidFinishTestRun = new vscode.EventEmitter<TestFinishEvent>();
private context: IRunTestContext;
private testRunnerApi: any;

Check warning on line 14 in extension/src/bs/GradleTestRunner.ts

View workflow job for this annotation

GitHub Actions / Build & Analyse

Unexpected any. Specify a different type

public onDidChangeTestItemStatus: vscode.Event<TestItemStatusChangeEvent> = this._onDidChangeTestItemStatus.event;
public onDidFinishTestRun: vscode.Event<TestFinishEvent> = this._onDidFinishTestRun.event;

constructor(testRunnerApi: any) {

Check warning on line 19 in extension/src/bs/GradleTestRunner.ts

View workflow job for this annotation

GitHub Actions / Build & Analyse

Unexpected any. Specify a different type
this.testRunnerApi = testRunnerApi;
}

public launch(context: IRunTestContext): void {
public async launch(context: IRunTestContext): Promise<void> {
this.context = context;
const tests: Map<string, string[]> = new Map();
context.testItems.forEach((testItem) => {
Expand All @@ -43,15 +43,19 @@
const agrs = context.testConfig?.args;
const vmArgs = context.testConfig?.vmArgs;
const env = context.testConfig?.env;
vscode.commands.executeCommand(
"java.execute.workspaceCommand",
"java.gradle.delegateTest",
context.projectName,
JSON.stringify([...tests]),
agrs,
vmArgs,
env
);
try {
await vscode.commands.executeCommand(
"java.execute.workspaceCommand",
"java.gradle.delegateTest",
context.projectName,
JSON.stringify([...tests]),
agrs,
vmArgs,
env
);
} catch (error) {
this.finishTestRun(-1, error.message);
}
}

public updateTestItem(
Expand Down
4 changes: 2 additions & 2 deletions extension/src/java-test-runner.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
*/
export interface TestRunner {
/**
* launch test test execution.
* launch the test execution.
* @param context the context for this test run.
*/
launch(context: IRunTestContext): void;
launch(context: IRunTestContext): vscode.ProviderResult<void>;

/**
* Event that should be emitted when the status of a test item changes.
Expand Down Expand Up @@ -271,7 +271,7 @@
* The command line arguments which will be passed to the test runner.
* @since 0.14.0
*/
args?: any[];

Check warning on line 274 in extension/src/java-test-runner.api.ts

View workflow job for this annotation

GitHub Actions / Build & Analyse

Unexpected any. Specify a different type

/**
* The path to java executable to use. If undefined project JDK's java executable is used.
Expand All @@ -283,7 +283,7 @@
* the extra options and system properties for the JVM.
* @since 0.14.0
*/
vmArgs?: any[];

Check warning on line 286 in extension/src/java-test-runner.api.ts

View workflow job for this annotation

GitHub Actions / Build & Analyse

Unexpected any. Specify a different type

/**
* The extra environment variables when running the tests.
Expand Down
Loading