Repository navigation
fix(run): preserve test runner arguments, build before test launch, and support JUnit 6 - #41
Merged
Merged
Conversation
…and support JUnit 6
1lck
marked this pull request as ready for review
November 20, 2026 09:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 类型 / Type
根因与改动 / Root Cause & Changes
根因
crates/java-domain/src/debug/java_test.rs中的java_test_launch为满足 DAP 接口,将args和vmArgs序列化成单个 JSON 字符串(Value::String);但backend/src/run.rs的test_process通过launch_arguments读取它们时使用Value::as_array,导致所有 JVM 参数与 JUnit/TestNG 运行器参数(-port、-classNames、-test等)全部静默丢失,原单测仅以伪造 JSON 数组覆盖而未暴露该问题。com.microsoft.java.test.plugin-0.43.1.jar定义了TestKind.JUnit6 = 3,而plan_debug_launch仅匹配0 | 1 | 2。main_process不同,test_process未在LAUNCH_ARGUMENTS_COMMAND前调用vscode.java.buildWorkspace,修改/新建测试后可能读取陈旧字节码或缺少测试输出目录。collect_actions_function中若vscode.java.resolveMainMethod先遇到瞬态错误(如语言服务尚未完全就绪或繁忙),会直接早退并不再查询vscode.java.test.findTestTypesAndMethods,且两步各占 6000ms 超时可能超出宿主 8000ms 总预算。改动
crates/java-domain/src/debug/java_test.rs:JavaTestProcessLaunch结构体与java_test_process_launch(),返回强类型的vm_arguments/program_arguments(Vec<String>)供直接进程启动复用;保留java_test_launch()作为 DAP 薄封装以保持向后兼容。java_test_process_launch_keeps_typed_vm_and_runner_arguments。crates/java-domain/src/testing/jdt_test_items.rs:plan_debug_launch将0 | 1 | 3均映射为JavaTestFramework::Junit。junit_6_test_kind_plans_a_junit_launch。backend/src/run.rs:build_workspace()辅助函数,由main_process与test_process共用;test_process在解析启动计划后先执行增量构建并校验结果,再请求运行器参数。test_process改用java_test_process_launch与强类型process_launch_arguments(),移除误用Value::as_array的旧launch_arguments。COLLECT_REQUEST_TIMEOUT_MILLISECONDS调整为3_500ms,并通过combine_collection_outcomes/combine_collection_outcomes_with独立收集主方法与测试项:一侧遇到瞬态错误时仍保留另一侧已发现的动作,同时维持deferred重试标记。launch_arguments_follow_the_java_command_line_order测试(process_launch_arguments_keep_domain_vm_and_runner_arguments、transient_main_method_failure_does_not_suppress_discovered_tests)。验证 / Verification
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --lockedlithe-java-backend165 unit + 10repository_pins+ 4session,lithe-java-domain284 unit,0 failed)./scripts/verify-sdk-lock.shjava-debug/java-testBundle 冒烟(临时 Maven JUnit 5 项目)findTestTypesAndMethods→buildWorkspace→vscode.java.test.junit.argument→RemoteTestRunner执行,收到%TESTC/%TESTS/%TESTE/%RUNTIME58且退出码为 0,已清理临时目录与进程)未在本次执行的检查说明:
python3 scripts/verify-contract.py因本机 Python 缺少jsonschema模块未能运行(本次未修改plugin.json或契约文件)。