Skip to content
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

Add preference to autosave when 'Run Test' is selected. #468

Closed
NikolasKomonen opened this issue Nov 28, 2018 · 11 comments · Fixed by #785
Closed

Add preference to autosave when 'Run Test' is selected. #468

NikolasKomonen opened this issue Nov 28, 2018 · 11 comments · Fixed by #785
Milestone

Comments

@NikolasKomonen
Copy link

When I run a test would it be possible to have a preference to autosave the project?

Thanks

@jdneo
Copy link
Member

jdneo commented Nov 29, 2018

@NikolasKomonen Do you mean to save all the changed files before running the tests?

@NikolasKomonen
Copy link
Author

Do you mean to save all the changed files before running the tests?

@jdneo yes

@baker-travis
Copy link

Or even just the test file you push the run button from. I often find myself writing a test and then running and not getting expected results because the test file didn't save.

@jdneo
Copy link
Member

jdneo commented Feb 9, 2019

@NikolasKomonen @baker-travis

From my understanding, the Java language server will auto-build the workspace when the file is changed(No matter the file is saved or not).

Do you guys stably meet this problem, or it just happens sometimes?

@NikolasKomonen
Copy link
Author

@jdneo

Sorry, what I wanted was basically what @baker-travis was asking for.
If the tests are run in any way, to save the file before they execute.

And if

the Java language server will auto-build the workspace when the file is changed

is the case, I guess just saving the test files will do.

@jdneo
Copy link
Member

jdneo commented Feb 12, 2019

@NikolasKomonen After trying, it's just the same as what you said. The Language Server will only update the class file after the saving action.

So here is the basic idea coming up in my mind to solve this issue:

The experience could be similar to that in Eclipse:
wechat screenshot_20190212095502

When the user click run/debug test cases, we do the following things:

  1. Find out all the relative files that are going to be tested
  2. If there is any dirty file, show a drop-down list in the VS Code, the user can select which file they want to save using the checkbox. Here ESC meaning to cancel the task.
  3. After that, a dialog will be shown to ask the user if he wants to always save the files before launching.
  4. The extension will wait for the Language Server to finish the auto-build, then, launch the tests.

@NikolasKomonen @baker-travis Please let me know if this looks good to you.

@baker-travis
Copy link

@jdneo I approve of this. 😀It will make life much better!

@NikolasKomonen
Copy link
Author

@jdneo Sounds great, I'm looking forward to it!

@jdneo
Copy link
Member

jdneo commented May 28, 2019

Update:

To implement this feature, we need VS Code to provide the API to get all the opened editors. So far it seems that there is no such API to achieve this. See: microsoft/vscode#15178

@jdneo
Copy link
Member

jdneo commented Aug 21, 2019

Hi @ALL,

Sorry for the late reply. Instead of get all opened files in VS Code. I simplified the solution to solve this issue:

  1. Provide a setting java.test.saveAllBeforLaunchTest to specify whether to save all the changed files before launch the test
  2. save all the files if this setting is true.

More details can be found in #785.

Note: together with the setting java.test.forceBuildBeforeLaunchTest set to true (See: #782). We can make sure the bits are latest for each test execution.

@NikolasKomonen
Copy link
Author

Awesome, thanks!

@jdneo jdneo added this to the 0.19.1 milestone Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants