|
| 1 | +import { ProcessArgumentBuilder } from '../interop/processArgumentBuilder'; |
1 | 2 | import { DotNetTaskProvider } from '../providers/dotnetTaskProvider'; |
2 | 3 | import { TestExtensions } from '../models/test'; |
3 | 4 | import { Interop } from '../interop/interop'; |
@@ -57,24 +58,28 @@ export class TestExplorerController { |
57 | 58 | } |
58 | 59 | private static async runTests(request: vscode.TestRunRequest, token: vscode.CancellationToken): Promise<void> { |
59 | 60 | TestExplorerController.convertTestRequest(request).forEach(async (filters, project) => { |
| 61 | + const preLaunchTask = await Extensions.getTask(Extensions.getSetting<string>(res.configIdTestExplorerPreLaunchTask)); |
60 | 62 | const testReport = path.join(TestExplorerController.testsResultDirectory, `${project.label}.trx`); |
61 | 63 | if (fs.existsSync(testReport)) |
62 | 64 | vscode.workspace.fs.delete(vscode.Uri.file(testReport)); |
63 | 65 |
|
64 | | - const testArguments: string[] = ['--logger', `'trx;LogFileName=${testReport}'`]; |
65 | | - if (filters.length > 0) { |
66 | | - testArguments.push('--filter'); |
67 | | - testArguments.push(`'${filters.join('|')}'`); |
68 | | - } |
| 66 | + const testArguments = new ProcessArgumentBuilder('test') |
| 67 | + .append('--logger').append(`'trx;LogFileName=${testReport}'`); |
| 68 | + |
| 69 | + testArguments.conditional('--no-build', () => preLaunchTask !== undefined); |
| 70 | + testArguments.conditional('--filter', () => filters.length > 0); |
| 71 | + testArguments.conditional(`'${filters.join('|')}'`, () => filters.length > 0); |
69 | 72 |
|
70 | 73 | const testRun = TestExplorerController.controller.createTestRun(request); |
| 74 | + await Extensions.waitForTask(preLaunchTask); |
71 | 75 | await Extensions.waitForTask(DotNetTaskProvider.getTestTask(project.uri!.fsPath, testArguments)); |
72 | 76 | await TestExplorerController.publishTestResults(testRun, project, testReport); |
73 | 77 | }); |
74 | 78 | } |
75 | 79 | private static async debugTests(request: vscode.TestRunRequest, token: vscode.CancellationToken): Promise<void> { |
76 | 80 | TestExplorerController.convertTestRequest(request).forEach(async (filters, project) => { |
77 | | - const executionSuccess = await Extensions.waitForTask(DotNetTaskProvider.getBuildTask(project.uri!.fsPath)); |
| 81 | + const preLaunchTask = await Extensions.getTask(Extensions.getSetting<string>(res.configIdTestExplorerPreLaunchTask)); |
| 82 | + const executionSuccess = await Extensions.waitForTask(preLaunchTask ?? DotNetTaskProvider.getBuildTask(project.uri!.fsPath)); |
78 | 83 | if (!executionSuccess || token.isCancellationRequested) |
79 | 84 | return; |
80 | 85 |
|
|
0 commit comments