-
Notifications
You must be signed in to change notification settings - Fork 337
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 test discovery endpoint #3277
Conversation
This looks super cool @kpodsiad! I haven't looked super close yet, but what does come to mind right away is that I want to see if it's possible to use with with |
Excellent stuff @kpodsiad. I look forward to the day I don't have to scroll through log output to see why tests are failing. The additional features you talk about would be great. But even if it's not currently possible to run individual tests - I think viewing finer granulation of test results would be immensely helpful. In the tree view - having each individual test result as a leaf node below its test suite node and then being able to select them and see the expected/obtained/diff would speed up the development cycle. To be able to then re-run only that failing test would be icing on the cake. |
It isn't easy since the only information Metals got from the build server is a test's class name. Using the class name we should be able to determine to which test framework class belongs and then apply some logic to extract singular tests position and name. Fact that this extraction logic has to be implemented per each test framework worries me, but I don't know if there's a better approach
It isn't easy since the only information Metals got from the build server is a test's class name. Using the class name we should be able to determine to which test framework class belongs and then apply some logic to extract singular tests position and name. Fact that this extraction logic has to be implemented per each test framework worries me, but I don't know if there's a better approach
Assuming that the former part is already done this should be relatively easy, at least partially. Thanks to changes in scala-debug-adapter and bloop, both sbt and bloop will send "detailed" info about each test. "detailed" because for errors it will only contain
Say no more! I have one idea of how to pursue this, but I don't know how what the outcome will be since probably it requires changes in a few places :/ Out of curiosity, what test framework do you use most frequently @Arthurm1 ? |
@kpodsiad I use JUnit 5 for java code and Scalatest for scala code. Sadly Bloop doesn't support Junit 5 see here so I use Intellij. It's probably fine to rely on the test framework's text output. JUnit displays actual & expected. MUnit does as well if I remember correctly. The main thing I would like is the ability to click on a failed test and have the results of that specific test appear (whatever format that is) rather than having to scroll through logs to find out why that test failed. I don't know about you but I find something like Github's way of displaying test results quite slow to drill into/navigate and that's what I would like to get away from here. |
2945202
to
495e0bf
Compare
tests/unit/src/test/scala/tests/testProvider/DiscoverTestClassesSuite.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestDiscovery.scala
Outdated
Show resolved
Hide resolved
e2a3f21
to
8de8c2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool @kpodsiad! 🚀
Once I get a bit more time I'd like to see if it's possible for us to support this in nvim-metals
. I love to have something like this.
Just a few nits, no blockers from my side.
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesFinder.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestDiscovery.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesFinder.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesFinder.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesFinder.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesFinder.scala
Outdated
Show resolved
Hide resolved
Even if it is not possible to add some structured view about I think that other editors can still benefit from this and following PR's. Namely, if Metals will be able to discover single tests inside the test suite and build-server-protocol/build-server-protocol#249 will be added and implemented by build servers then Metals' clients can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @kpodsiad
I left a bunch of comments, I think we can simplify a couple of things.
metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/UserConfiguration.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesFinder.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesFinder.scala
Outdated
Show resolved
Hide resolved
tests/unit/src/test/scala/tests/testProvider/DiscoverTestSuitesSuite.scala
Outdated
Show resolved
Hide resolved
tests/unit/src/test/scala/tests/testProvider/DiscoverTestSuitesSuite.scala
Outdated
Show resolved
Hide resolved
tests/unit/src/test/scala/tests/testProvider/DiscoverTestSuitesSuite.scala
Outdated
Show resolved
Hide resolved
tests/unit/src/test/scala/tests/testProvider/DiscoverTestSuitesSuite.scala
Outdated
Show resolved
Hide resolved
tests/unit/src/test/scala/tests/testProvider/DiscoverTestSuitesSuite.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some small comments and we should probably add a bit more testing.
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuiteDiscoveryResult.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuiteDiscoveryResult.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuiteDiscoveryResult.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesFinder.scala
Outdated
Show resolved
Hide resolved
tests/unit/src/test/scala/tests/testProvider/TestSuitesFinderSuite.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great work!
Adds endpoint which returns information about tests in targets in projects. This information can be consumed by LSP clients.
Needs:
Tests are run using a DAP server - just like code lenses are. In addition, if it's possible (e.g. running tests for the whole project), tests are batched and run using a single DAP session because creating the DAP session takes some time.
Information about text execution is passed from Build Server (for now it's only implemented for Bloop) to the DAP server, then the server forwards this event to the DAP client. The event contains sufficient information about the execution of both the whole test suite and particular test cases.
There are a few things which would be great to have:
sbt-test-interface
and there is no sufficient information for diff or other fancier stuff. For now, we'll have to live with plainthrowable.getMessage()
It turned out that this can be done even better, every test can have its own section in the test suite summary.