diff --git a/package.json b/package.json index 57cac05f..2dca94db 100644 --- a/package.json +++ b/package.json @@ -200,6 +200,30 @@ "description": "%configuration.java.test.config.classPaths.description%", "default": [] }, + "modulePaths": { + "type": "array", + "items": { + "anyOf": [ + { + "enum": [ + "$Auto", + "$Runtime", + "$Test", + "!" + ], + "enumDescriptions": [ + "%configuration.java.test.config.modulePaths.auto.description%", + "%configuration.java.test.config.modulePaths.runtime.description%", + "%configuration.java.test.config.modulePaths.test.description%", + "%configuration.java.test.config.modulePaths.exclude.description%" + ] + }, + "string" + ] + }, + "description": "%configuration.java.test.config.modulePaths.description%", + "default": [] + }, "vmArgs": { "type": "array", "items": { @@ -280,6 +304,30 @@ "description": "%configuration.java.test.config.classPaths.description%", "default": [] }, + "modulePaths": { + "type": "array", + "items": { + "anyOf": [ + { + "enum": [ + "$Auto", + "$Runtime", + "$Test", + "!" + ], + "enumDescriptions": [ + "%configuration.java.test.config.modulePaths.auto.description%", + "%configuration.java.test.config.modulePaths.runtime.description%", + "%configuration.java.test.config.modulePaths.test.description%", + "%configuration.java.test.config.modulePaths.exclude.description%" + ] + }, + "string" + ] + }, + "description": "%configuration.java.test.config.modulePaths.description%", + "default": [] + }, "vmargs": { "type": "array", "items": { diff --git a/package.nls.json b/package.nls.json index 0c59bf09..aa2d2fdf 100644 --- a/package.nls.json +++ b/package.nls.json @@ -10,11 +10,16 @@ "configuration.java.test.config.item.description": "Specify the configuration item for running the tests", "configuration.java.test.config.name.description": "Specify the name of the configuration item", "configuration.java.test.config.workingDirectory.description": "Specify the working directory when running the tests", - "configuration.java.test.config.classPaths.description": "The classpath defined in this setting will be appended to the resolved classpath", + "configuration.java.test.config.classPaths.description": "The classpaths defined in this setting will be appended to the resolved classpaths", "configuration.java.test.config.classPaths.auto.description": "Automatically resolve the classpaths of current project", "configuration.java.test.config.classPaths.runtime.description": "The classpaths within 'runtime' scope of current project", "configuration.java.test.config.classPaths.test.description": "The classpaths within 'test' scope of current project", "configuration.java.test.config.classPaths.exclude.description": "The path after '!' will be excluded from the classpaths", + "configuration.java.test.config.modulePaths.description": "The modulepaths defined in this setting will be appended to the resolved modulepaths", + "configuration.java.test.config.modulePaths.auto.description": "Automatically resolve the modulepaths of current project", + "configuration.java.test.config.modulePaths.runtime.description": "The modulepaths within 'runtime' scope of current project", + "configuration.java.test.config.modulePaths.test.description": "The modulepaths within 'test' scope of current project", + "configuration.java.test.config.modulePaths.exclude.description": "The path after '!' will be excluded from the modulePaths", "configuration.java.test.config.vmArgs.description": "Specify the extra options and system properties for the JVM", "configuration.java.test.config.args.description": "Specify the command line arguments which will be passed to the test runner", "configuration.java.test.config.env.description": "Specify the extra environment variables when running the tests", diff --git a/package.nls.zh.json b/package.nls.zh.json index 9ee8d5ed..87da699d 100644 --- a/package.nls.zh.json +++ b/package.nls.zh.json @@ -15,6 +15,11 @@ "configuration.java.test.config.classPaths.runtime.description": "当前工程中属于 runtime 作用域的类路径", "configuration.java.test.config.classPaths.test.description": "当前工程中属于 test 作用域的类路径", "configuration.java.test.config.classPaths.exclude.description": "'!' 之后的路径将会从类路径中去除", + "configuration.java.test.config.modulePaths.description": "通过该配置项设置的模块路径会被追加到自动解析的模块路径上", + "configuration.java.test.config.modulePaths.auto.description": "自动从当前工程中解析模块路径", + "configuration.java.test.config.modulePaths.runtime.description": "当前工程中属于 runtime 作用域的模块路径", + "configuration.java.test.config.modulePaths.test.description": "当前工程中属于 test 作用域的模块路径", + "configuration.java.test.config.modulePaths.exclude.description": "'!' 之后的路径将会从模块路径中去除", "configuration.java.test.config.vmArgs.description": "设定启动 JVM 的额外选项和系统属性", "configuration.java.test.config.args.description": "设定启动 Test Runner 时的命令行参数", "configuration.java.test.config.env.description": "启动应用程序时自定义的环境变量", diff --git a/src/runConfigs.ts b/src/runConfigs.ts index 0be6ffbf..954b4398 100644 --- a/src/runConfigs.ts +++ b/src/runConfigs.ts @@ -9,47 +9,62 @@ export interface IExecutionConfig { * @since 0.14.0 */ name?: string; + /** * The working directory when running the tests. * @since 0.14.0 */ workingDirectory?: string; + /** - * The classpath defined in this setting will be appended to the resolved classpath. + * The classpaths defined in this setting will be appended to the resolved classpaths. * @since 0.33.0 */ - classPaths?: string[] + classPaths?: string[] + + /** + * The modulepaths defined in this setting will be appended to the resolved modulepaths + * @since 0.33.0 + */ + modulePaths?: string[] + /** * The command line arguments which will be passed to the test runner. * @since 0.14.0 */ args?: any[]; + /** * the extra options and system properties for the JVM. * It's deprecated, we should align with the debug launch configuration, which is 'vmArgs'. * @since 0.14.0 */ vmargs?: any[]; + /** * the extra options and system properties for the JVM. * @since 0.14.0 */ vmArgs?: any[]; + /** * The extra environment variables when running the tests. * @since 0.25.0 */ env?: { [key: string]: string; }; + /** * The absolute path to a file containing environment variable definitions. * @since 0.33.0 */ envFile?: string; + /** * The extra source paths when debugging the tests * @since 0.22.4 */ sourcePaths?: string[]; + /** * The label of a task specified in tasks.json. * @since 0.33.0 diff --git a/src/utils/launchUtils.ts b/src/utils/launchUtils.ts index 752ed23d..2b736ec7 100644 --- a/src/utils/launchUtils.ts +++ b/src/utils/launchUtils.ts @@ -32,11 +32,14 @@ export async function resolveLaunchConfigurationForRunner(runner: BaseRunner, te cwd: config && config.workingDirectory ? config.workingDirectory : launchArguments.workingDirectory, classPaths: [ ...config?.classPaths || [], - ...launchArguments.classpath, + ...launchArguments.classpath || [], path.join(extensionContext.extensionPath, 'server', 'com.microsoft.java.test.runner.jar'), path.join(extensionContext.extensionPath, 'server', 'lib'), ], - modulePaths: launchArguments.modulepath, + modulePaths: [ + ...config?.modulePaths || [], + ...launchArguments.modulepath || [], + ], args: runner.getApplicationArgs(config), vmArgs: launchArguments.vmArguments, env: config?.env, @@ -56,9 +59,12 @@ export async function resolveLaunchConfigurationForRunner(runner: BaseRunner, te cwd: config && config.workingDirectory ? config.workingDirectory : launchArguments.workingDirectory, classPaths: [ ...config?.classPaths || [], - ...launchArguments.classpath, + ...launchArguments.classpath || [], + ], + modulePaths: [ + ...config?.modulePaths || [], + ...launchArguments.modulepath || [], ], - modulePaths: launchArguments.modulepath, args: launchArguments.programArguments, vmArgs: launchArguments.vmArguments, env: config?.env, diff --git a/test/suite/config.test.ts b/test/suite/config.test.ts index 747010ad..e7edfab1 100644 --- a/test/suite/config.test.ts +++ b/test/suite/config.test.ts @@ -46,6 +46,9 @@ suite('JUnit Runner Analyzer Tests', () => { "/a/b/c.jar", "/foo/bar.jar" ], + modulePaths: [ + "/test/module.jar", + ], env: { test: "test", }, @@ -57,8 +60,9 @@ suite('JUnit Runner Analyzer Tests', () => { }); assert.strictEqual(configuration.env.test, "test"); assert.strictEqual(configuration.envFile, "${workspaceFolder}/.env"); - assert.strictEqual(configuration.sourcePaths?.[0], "/a/b/c.jar"); + assert.strictEqual(configuration.sourcePaths[0], "/a/b/c.jar"); assert.strictEqual(configuration.preLaunchTask, "test"); + assert.strictEqual(configuration.modulePaths[0], "/test/module.jar"); assert.strictEqual(configuration.classPaths[0], "/a/b/c.jar"); assert.strictEqual(configuration.classPaths[1], "/foo/bar.jar"); });