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

Allow Test Explorer UI To Automatically Trigger Testing On Save #1952

Open
sheldonhull opened this issue Dec 16, 2021 · 4 comments
Open

Allow Test Explorer UI To Automatically Trigger Testing On Save #1952

sheldonhull opened this issue Dec 16, 2021 · 4 comments
Labels
go-test issues related to go test support (test output, test explorer, ...) upstream-vscode Issues that are by problems in VS Code itself.

Comments

@sheldonhull
Copy link

sheldonhull commented Dec 16, 2021

I love the test explorer UI and want to use more regularly for TDD.

In the settings, there is an option to run tests on save, but this doesn't seem to integrate with, or having any settings related to the test explorer ui.

What I'd love to see is the Test Explorer UI offer some custom settings such as:

"go.testExplorer.tests": {

	"runonsave": "currentfunction|currentfile|currentpackage|currentworkspace",
    "showtestexplorerwhentriggered": true,
    "expandtocurrenttestwhenrun": true,
    "delayaftersaveinseconds": 1,
} 

I really want to use this nice explorer on the side to do red/green style TDD, but clicking each time from my code file to the test ui or the play button is not a smooth process to regularly run on changes.

edit:
The equivalent in Goland is a file watcher than runs tests on save with a slight delay, and works well, although not as granular as it might be with the pattern above.

@gopherbot gopherbot added this to the Untriaged milestone Dec 16, 2021
@hyangah hyangah added the go-test issues related to go test support (test output, test explorer, ...) label Dec 17, 2021
@hyangah hyangah modified the milestones: Untriaged, Unplanned Dec 17, 2021
@firelizzard18
Copy link
Contributor

The old test infrastructure and the new test explorer UI implementation are separate. The Go: Test On Save option works with the old infrastructure. We do plan to merge the two implementations, but since October I haven't had any time to contribute to this project (I wrote the test explorer implementation).

One of the proposed APIs allows an extension to invalidate the results for specific tests. If auto-run is enabled in the test explorer, invalidated tests will be automatically re-run.

expandToCurrentTestWhenRun is already implemented by VSCode as testing.followRunningTest. For showTestExplorerWhenTriggered, please submit a feature request to VSCode. It is more appropriate to implement that functionality in the test explorer UI, as opposed to in the Go extension's test controller implementation.

@hyangah
Copy link
Contributor

hyangah commented Jan 18, 2022

Thanks @firelizzard18 for the insight.
I guess you meant microsoft/vscode#134941 the auto-run feature.
I agree that it's language-agnostic feature and it's desirable if offered from VSCode level.

@hyangah hyangah added the upstream-vscode Issues that are by problems in VS Code itself. label Jan 18, 2022
@firelizzard18
Copy link
Contributor

Related: #2483

@firelizzard18
Copy link
Contributor

Today in #3523 I implemented support for VSCode's continuous test runs. Specifically, if you click
the icon VSCode will start a continuous test run. When a test is modified, it will be marked as such and will be executed when the document is saved. There is not support for detecting modifications to dependencies - that would need to be handled by source analysis in gopls and currently there's no mechanism for that - no mechanism for gopls to notify the extension that some code relevant to a test has changed - as far as I know. This is separate from test run invalidation. To support continuous runs I have to explicitly trigger a test run. Invalidation does not trigger a run in continuous mode, as I thought it would.

@sheldonhull I'm guessing this does not meet your needs, since it sounds like you want updates to related code to trigger runs. It would be feasible to have some simple logic, such as "when any file in package X changes, rerun every test in package X (when a continuous run is active)". However I think the other settings you're requesting such as "showtestexplorerwhentriggered" should be separate requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go-test issues related to go test support (test output, test explorer, ...) upstream-vscode Issues that are by problems in VS Code itself.
Projects
Status: No status
Development

No branches or pull requests

4 participants