我试图在运行 JUnit 测试时调试一个类,但是,我的配置似乎不正确:
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Maven: compile",
"type": "shell",
"command": "mvn",
"args": ["compile"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$maven"],
"detail": "Compile the project using Maven"
},
{
"label": "Maven: test",
"type": "shell",
"command": "mvn",
"args": ["test"],
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": ["$maven"],
"dependsOn": "Maven: compile",
"detail": "Run all tests using Maven"
},
{
"label": "Maven: test XodusDatabaseTest",
"type": "shell",
"command": "mvn",
"args": ["compile", "test", "-Dtest=XodusDatabaseTest"],
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": ["$maven"],
"detail": "Run XodusDatabaseTest using Maven"
},
{
"label": "Maven: debug XodusDatabaseTest",
"type": "shell",
"command": "mvn",
"args": [
"compile",
"test",
"-Dtest=XodusDatabaseTest",
"-Dmaven.surefire.debug"
],
"problemMatcher": ["$maven"],
"detail": "Debug XodusDatabaseTest using Maven"
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug Test XodusDatabaseTest",
"request": "launch",
"mainClass": "",
"preLaunchTask": "Maven: debug XodusDatabaseTest",
"cwd": "${workspaceFolder}",
"vmArgs": "-Dfile.encoding=UTF-8",
"console": "integratedTerminal",
"debugServer": 5005
}
]
}
运行“调试测试...”卡住等待调试器:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Listening for transport dt_socket at address: 5005
我希望它继续进行单元测试并在 VScode 中设置的任何断点处停止。