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
295 stars 129 forks source link

Expose lists of tests to be usable in inputs of task.json #1405

Open matter-it-does opened 2 years ago

matter-it-does commented 2 years ago

I want to write a task like

"inputs": [
    {
      "id": "pickedTest",
      "type": "command",
      "command": "extension.yourextension.testPickerinCurrentFile",
    }
  ],

"tasks": [{
  "type": "shell",
  "command": "mvn -Dtest=${input:pickedTest} test -e",
  "label": "run test.."
}]

to be able to run any test(s) in current file or the entire workspace in my terminal instead of the debug console.

so if you exposed two commands

with full classpath and/or methodname as output which can directly be fed to maven, I'd be grateful.

jdneo commented 2 years ago

We have commands to run/debug tests in current file or at current cursor position:

image

Will they meets your requirement?

matter-it-does commented 2 years ago

That would still run the test in VScode testing UX with output in Testing view and debug console.

I want to invoke maven and run the command in the integrated terminal (zsh if that matters). See the example given in VSCode docs

An example of this functionality is in VS Code's Node.js debugger extension, which provides an interactive command >extension.pickNodeProcess for selecting a single process from the list of all running Node.js processes. The command >returns the process ID of the selected process. This makes it possible to use the extension.pickNodeProcess command in >an Attach by Process ID launch configuration in the following way:

https://code.visualstudio.com/docs/editor/variables-reference#_command-variables

similar to this but instead of launch.json, it's task.json and instead of PID, it's test.

matter-it-does commented 2 years ago

Where this extension can help is saving me all that typing the full classname#methodname

jdneo commented 2 years ago

I see.

One more question: would you mind explaining the reason for running from command line via maven, instead of the testing ui? Is that because the testing ui has bugs?

matter-it-does commented 2 years ago

I do use the testing UI for debugging a test though, works great, mostly because I don't know the java command to do so. Though I found it out by using https://stackoverflow.com/questions/821837/how-to-get-the-command-line-args-passed-to-a-running-process-on-unix-linux-syste

jdneo commented 2 years ago

I don't like the peek view of the failed test. too intrusive. Jumping from the stacktrace to files is also clunky.

The peek view is controlled by VS Code (we call the API to provide content). Could you explain more about the 'instrusive' and 'clunky' part.

Debug console doesn't allow jumping to file location outputted by the logger.

Is it possible to provide a screenshot for the case when navigation is not working?

matter-it-does commented 2 years ago

I don't like the peek view of the failed test. too intrusive. Jumping from the stacktrace to files is also clunky.

The peek view is controlled by VS Code (we call the API to provide content).

Oh I'm aware of that. Was going through some old issues and old readme and I kinda liked the old test failure report that opened in a split view.

Could you explain more about the 'instrusive' and 'clunky' part.

Intrusive is that it gets in the way of code, has a different scrolling context. Clunky: let's say there's an assertion failure in a test. I expand the peek view, see a stacktrace and click on one of the file:line mentioned. I come back and now the view is closed, so I have to open it again to see other lines.

To get it out of the way I use

image

this button but now the file:line navigation doesn't work in the new tab.

Ofc I don't blame this extension for that.

Debug console doesn't allow jumping to file location outputted by the logger.

Is it possible to provide a screenshot for the case when navigation is not working?

image

I'd be able to jump from integrated terminal to ConcurrentHashMap.java:4649 but not from debug console.

jdneo commented 2 years ago

Intrusive is that it gets in the way of code, has a different scrolling context. Clunky: let's say there's an assertion failure in a test. I expand the peek view, see a stacktrace and click on one of the file:line mentioned. I come back and now the view is closed, so I have to open it again to see other lines.

Thank you for the detailed information. We will convey those feedbacks to VS Code teams and hope they can address those UX issues.

this button but now the file:line navigation doesn't work in the new tab.

This issue is tracked here: https://github.com/microsoft/vscode/issues/140588. Feel free to add your vote to push the VS Code team implements it. :)

@testforstephen The last part of the user's feedback is about supporting code navigation from the logs in debug console. Do you have any input for that?

matter-it-does commented 2 years ago

@testforstephen hi, fixing the navigation from debug console to file would be great. that will also reduce the priority of this enhancement request for me. I have modified the logs format to match what vscode expects to jump to a file: file#line.. only if I could now click it.

thanks

testforstephen commented 2 years ago

@matter-it-does In Debug Console, we already supports showing a file link when detecting it's a stacktrace print line. It's doable to relax matching rules and apply them to other log lines.

image

matter-it-does commented 2 years ago

yes I also mentioned it in https://github.com/microsoft/vscode-java-test/issues/1405#issuecomment-1097521274

A java extension can expect *.java files followed by a separator (:, # etc ) followed by numbers.

jdneo commented 2 years ago

It's doable to relax matching rules and apply them to other log lines.

@testforstephen should I file an issue for this in debug repo? Or you prefer to track this here?