-
Notifications
You must be signed in to change notification settings - Fork 156
Run with Configuration
You can run tests with custom configuration. The configuration can be specified in settings.json
using the key java.test.config
.
It's recommended to save the test configuration as workspace settings. To open workspace settings, run command
Preferences: Open Workspace Settings (JSON)
.
Here is an example of the configuration schema:
"java.test.config": [
{
"name": "myConfiguration",
"workingDirectory": "${workspaceFolder}",
"args": [ "-c", "com.test" ],
"vmargs": [ "-Xmx512M" ],
"env": { "key": "value" },
},
{
// Another configuration item...
},
...
]
Note: The commands
Run With Configuration
andDebug With Configuration
are removed from version0.14.0
. The extension will let you select the configuration if it detects there are customized configuration available.
The value of java.test.config
is an object or an object array, each object is a configuration item, which may have the following properties:
Property Name | Description | Default Value | Since |
---|---|---|---|
args |
Specify the command line arguments which will be passed to the test runner | [] | 0.14.0 |
classPaths |
The classpaths defined in this setting will be appended to the resolved classpaths | [] | 0.33.0 |
env |
Specify the extra environment variables when running the tests | {} | 0.14.0 |
envFile |
Specify the absolute path to a file containing environment variable definitions | {} | 0.33.0 |
modulePaths |
The modulepaths defined in this setting will be appended to the resolved modulepaths | [] | 0.33.0 |
name |
Specify the name of the configuration item | "" | 0.14.0 |
preLaunchTask |
Specify the label of a task specified in tasks.json (in the workspace's .vscode folder). The task will be launched before the start of testing | "" | 0.33.0 |
sourcePaths |
Specify the extra source paths when debugging the tests | [] | 0.22.4 |
vmArgs |
Specify the extra options and system properties for the JVM | [] | 0.25.0 |
workingDirectory |
Specify the working directory when running the tests | "${workspaceFolder}" | 0.14.0 |
When you have custom configurations, you'll be asked to pick one every time when running/debugging your test cases. To avoid that, you can use java.test.defaultConfig
and set its value to the name of a configuration.
If you want to bypass any existing configurations, you can use the built-in configuration named "default" which has the following definition:
{
"name": "default",
"workingDirectory": "${workspaceFolder}"
}