microsoft / vscode-java-test

Run and debug Java test cases in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test
Other
291 stars 125 forks source link

Shead some light on this extension regarding its working #1707

Open nithinbandaru1 opened 1 month ago

nithinbandaru1 commented 1 month ago

Hi,

I am trying to understand how this extension is working or what functionality does this extension is really providing.

I read about LSP here https://code.visualstudio.com/api/language-extensions/language-server-extension-guide and testing here https://code.visualstudio.com/docs/editor/testing at higher level and tried to create a picture how things are working and got these questions.

LSP server for Javat, hints I found in this extension https://marketplace.visualstudio.com/items?itemName=redhat.java description.

I see that this extension is dependent upon 2 java extensions.

Confusions:

  1. Probably not relevant question here, LSP client will communicate to server using which communication protocol? HTTP or WebSocket or pipe or TCP or any other as I read that LSP server will be running in separate process?

  2. I am guessing LSP server for Java is implemented in naive language itself that is java comes with above extensions indirectly using https://github.com/eclipse/eclipse.jdt.ls. Is that right?

  3. Is this extension a LSP client partial one covering test functionalities additionally with above two extensions covering other functionalities like linting, compiling etc.?

  4. I guess VS code Test Explorer will used this extension to discover tests from Java project. But I don't see what the need for this extension if it is only LSP client and not LSP server. I mean VS code Test Explorer would have generic base LSP client that will call specific LSP server based on loaded project and get the list of test cases. I don't see the need for some custom LSP client. LSP server would figure out what test framework is used and give list of tests right probably using reflection or build tool commands or something. So, I really do not understand what this extension is providing. Once I came across this https://github.com/eclipse/eclipse.jdt.ls being used, I am also guessing that this client implements Microsoft VS Code LSP definition and creates an adaptor between VS code LSP and Eclipse JDT LSP. Please can you Shead some light here?

  5. I believe LSP server would be written in Java itself because it will be more powerful than just looking Java file as text file. It gives capabilities to inspect contextual capabilities of code and show compile time errors, show intelligence code suggestions etc. which will be difficult to do when looking at these as simple text file. Am I right here?

I really appreciate if some knowledge is shared regarding above questions. Thanks, you.

jdneo commented 1 month ago

Hi @nithinbandaru1,

Would you mind sharing the goal or task you are working on to help me understand the context if the questions?

The JDT.LS and client uses pipe by default. But LSP itself does not limit you which way you need to use to communicate.

You can think this extension as an add-on for the JDT.LS, which adds the test coverage capabilities to it. And then this extension calls the testing api from vscode to show the test items in the test explorer.