New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension doesn't always compile code before running tests. #1629
Comments
What kind of project are you working on? Maven/Gradle? |
The one with no build tools. |
Hmm, I haven't heard this kind of feedback before. The extension should complete the compilation before running the tests. Could you share a snippet of your test cases? And the settings you are using? |
Here it is in action: It doesn't look like I've changed any settings in the extension. My java related settings:
The tests aren't anything special. They're only doing things in-memory with POJOs. I can send you the whole folder if you like, but I've seen this with multiple projects so I don't think the actual code is important. The project only depends on junit-platform-console-standalone-1.10.0.jar. Here's an example. It's from a Java course I teach. They're simulating a VM, but the test doesn't create any real threads or do anything like that.:
|
Have you set |
No, it wasn't set. I set it just to be sure, no change. |
Hmm.. The video about looks very like First time failed because it's running with the old class file. But the auto build will update the class file then, so the second time, the new class file has been generated. Without this, so far, I cannot imagine other causes that makes this. |
Maybe share the whole folder to let me check if I can repro from my side |
Maybe that setting isn't working?
In User/settings.json:
"java.debug.settings.forceBuildBeforeLaunch": true,
This is .vscode/settings.json:
{
"java.project.sourcePaths": ["src", "test"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": ["lib/**/*.jar"],
"java.format.settings.url": ".vscode/java-formatter.xml"
}
Screenshot of the settings editor attached.
…On Wed, Nov 1, 2023 at 7:49 AM Sheng Chen ***@***.***> wrote:
Hmm..
The video about looks very like java.debug.settings.forceBuildBeforeLaunch
is disabled.
First time failed because it's running with the old class file. But the
auto build will update the class file then, so the second time, the new
class file has been generated.
Without this, so far, I cannot imagine other causes that makes this.
—
Reply to this email directly, view it on GitHub
<#1629 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADDJ6VDNOLOBSO26AUWX6DDYCIZMTAVCNFSM6AAAAAA6VBRBWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBYHAZDIMRSGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
It works on my side. What is the probability of this happening? |
About 50%. I just tried it 20 times, 10 changing the test to fail and 10 changing it to pass. It worked correctly 5/10 changing it to fail, and 4/10 changing it to pass. |
I still suspect it an environment specific problem, because 50% is a very high ratio. If that applies to other users, we should receive quite a lot complains about this. What java related extensions are you installed? Is this behavior also observable from your colleague/students? |
Here are all of my extensions:
albert.TabOut
DavidAnson.vscode-markdownlint
dbaeumer.vscode-eslint
eamodio.gitlens
EditorConfig.EditorConfig
emeraldwalk.RunOnSave
esbenp.prettier-vscode
golang.go
mkhl.direnv
ms-python.isort
ms-python.python
ms-python.vscode-pylance
ms-vscode.hexeditor
ms-vscode.test-adapter-converter
redhat.fabric8-analytics
redhat.java
vadimcn.vscode-lldb
VisualStudioExptTeam.intellicode-api-usage-examples
VisualStudioExptTeam.vscodeintellicode
vscjava.vscode-java-debug
vscjava.vscode-java-dependency
vscjava.vscode-java-pack
vscjava.vscode-java-test
vscjava.vscode-maven
xaver.clang-format
yaozheng.vscode-pde
zxh404.vscode-proto3
I think the only Java related ones are the ones installed by the Java
extension pack, and Eclipse PDE support.
…On Wed, Nov 1, 2023 at 10:36 PM Sheng Chen ***@***.***> wrote:
I still suspect it an environment specific problem, because 50% is a very
high ratio. If that applies to other users, we should receive quite a lot
complains about this.
What java related extensions are you installed? Is this behavior also
observable from your colleague/students?
—
Reply to this email directly, view it on GitHub
<#1629 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADDJ6VGJL6NEITZULPTDASDYCMBK5AVCNFSM6AAAAAA6VBRBWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBZHE3DSNRWG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sorry @TimKingtonFC, one more question: Besides the test, is this behavior also observable if you run a main method? |
No, I'm not seeing it there.
I created a launch.json, and I'm hitting F5 with the file edited but not
saved, and it picked up the changes ten times in a row.
…On Tue, Nov 7, 2023 at 1:43 AM Sheng Chen ***@***.***> wrote:
Sorry @TimKingtonFC <https://github.com/TimKingtonFC>, one more question:
Besides the test, is this behavior also observable if you run a main
method?
—
Reply to this email directly, view it on GitHub
<#1629 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADDJ6VC7HDC2OKMTTRY3LG3YDHKCZAVCNFSM6AAAAAA6VBRBWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJXHEYDOMZYHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I tried it again on a Windows machine today, but still cannot find a way to reproduce it. Is this behavior also observable from your colleague/students? Sorry that I could not give more help so far. |
I just set up vscode fresh on a Windows machine, and it has the same
problem. I let vscode install Java 21, and have the same
setup/extensions/project.
…On Wed, Nov 8, 2023 at 3:19 AM Sheng Chen ***@***.***> wrote:
I tried it again on a Windows machine today, but still cannot find a way
to reproduce it.
Is this behavior also observable from your colleague/students?
Sorry that I could not give more help so far.
—
Reply to this email directly, view it on GitHub
<#1629 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADDJ6VHFMD4HNZUARHIT65DYDM6CBAVCNFSM6AAAAAA6VBRBWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBRGI4TONJRGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I've noticed a couple of other things that might be related. Fairly often - about once a day - I try to run my tests, and it gives me the popup that says the build failed, but the code is fine. It appears to be trying to build/run code from a few seconds earlier that didn't compile - I can tell from the error messages. Sometimes I can fix it by editing a file and saving, and sometimes I have to clean the Java workspace. A little less often - maybe every other day - something weird happens when I'm editing. I'll be typing code, and then some of the code I've just typed disappears. It's usually about half a line of code. IIRC, hitting undo readds the code that disappears, but I'm not 100% sure on that point. |
If I edit code and don't save the file, running the tests sometimes executes the old code.
When I click run, the files are saved, but there seems to be a race between the compiler and JUnit. Sometimes the compiler wins and things are okay, sometimes I get false test failures because JUnit is running the old code.
This is on MacOS 13.6, v0.40.0 of the runner, and vscode 1.83.1
The text was updated successfully, but these errors were encountered: