Closed heruan closed 9 months ago
Surprisingly enough, if I change this line
radioButtonGroup.setItemLabelGenerator(RadioButtonOption::getLabel);
to
radioButtonGroup.setItemLabelGenerator(option -> option.getLabel());
then it works, but if I change the other line from
.as(StringUtils::toStringArray)
to
.as(scope -> StringUtils.toStringArray(scope))
it still fails. Looks like it has something to do with type references in lambdas 🤔
Hi @heruan, thank you for reporting the issue.
I tried simply add some lambda code like
List<String> l = new ArrayList<>();
l.add("a");
l.stream().forEach(System.out::println);
but it still works.
Is it possible to share a sample project for this issue? It will help me a lot to fix the bug :)
Thanks for the feedback! Sure, here's the minimum code that I've been able to strip down to reproduce the issue: https://gist.github.com/heruan/817705978ad33926147ad8780785af4b
I've noticed that both line 11 and 16 have to be there to trigger the error, commenting either of those the test run fine.
Thank you @heruan!
The snippets are very helpful! The issue is fixed with https://github.com/microsoft/vscode-java-test/pull/1639/commits/4b6ccb67a45fea0fdb3a93be5e1fd2c84f550f83.
I'll schedule a new pre-release recently for this bug.
Thanks @jdneo! I'll test the pre-release once out. Out of curiosity, what's the cause of this?
Thank you, I'll let you know once the pre-release is out.
Some methods(lambda) miss debug information in the compiled class files. In such case, Jacoco returns -1
for the line of the methods and causes the issue.
Hi @heruan,
Would you mind trying this bit to see if the issue is fixed? vscode-java-test-0.40.2024030408.vsix.zip
I confirm this fixes the issue on my project, thanks!
Great! I'll schedule a pre-release then.
I'm using the Java Extensions Pack (pre-release) with Code Insiders and I'm experiencing a weird behavior with the new "Testing with coverage".
Suddenly I started getting this error when running Test with coverage:
So I inspected my latest changes and started commenting every line out until I've found two lines that once commented, get rid of the error.
and
Commenting out just the two
<-- THIS LINE ==|
lines makes the "Testing with coverage" to run fine.Notice that the two lines are on completely unrelated source files and the test run fails even if the test class does not involve any of those files. Both lines contains method references: there are other lines with method references that do not affect the test run, but these two lines have specific
Type::method
reference, while others areType::ctor
orinstance::method
.Let me know if I can provide any other information. Here's my environment:
Environment
Test Runner for Java
Version: v0.40.2024011806 (pre-release)
Visual Studio Code
Version: 1.87.0-insider (Universal) Commit: c11a2dd4d52e38cb92b8c464f47a7b02bb7c8762 Date: 2024-02-24T00:18:27.042Z Electron: 27.3.2 ElectronBuildId: 26836302 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0 OS: Darwin arm64 23.2.0