microsoft / build-server-for-gradle

An implementation of the Build Server Protocol for Gradle
MIT License
45 stars 7 forks source link

Support running main classes, tests and test discovery #124

Closed Arthurm1 closed 1 month ago

Arthurm1 commented 6 months ago

Implements BSP test discovery. Only returns the classes but BSP doesn't seem to allow test discovery down to the method level.

Requires Gradle >= 8.3 as --test-dry-run has only recently been added. There doesn't appear to be any other way to discover tests.

This is what this project looks like in VSCode test explorer image

Arthurm1 commented 5 months ago

Added support for buildTarget/test so tests can now be run at the class level.

I've also changed BuildTargetServerIntegrationTest to create a client for recording of server messages e.g. test reports.

Arthurm1 commented 5 months ago

Added support for buildTarget/run

Arthurm1 commented 3 months ago

rebased

jdneo commented 1 month ago

Hi @Arthurm1,

some rebase work might need for this PR. Before that, may I ask the reason why you want the BS to support test discovery?

(I haven't look through the change, but looks like test discovery is not covered in BSP, is it correct?)

Arthurm1 commented 1 month ago

rebased

(I haven't look through the change, but looks like test discovery is not covered in BSP, is it correct?)

Test discovery is a JVM only extension: https://build-server-protocol.github.io/docs/extensions/jvm#buildtargetjvmtestenvironment-request

Metals can do test discovery on its own on the currently open file but it's slightly painful as it has to know how to use each test framework and there are many: JUnit, TestNG, ScalaTest, MUnit, ScalaCheck, Specs2... Even with that, it wouldn't be able to discover any custom defined tests in Gradle

jdneo commented 1 month ago

My thought about the test support is that we can do it progressively.

So the first step can be:

The next step can be the discovery support (considering currently the test discovery only support the class level). WDYT?

And if possible, separate the the run and test support in different PRs would definitely help a lot :)

Arthurm1 commented 1 month ago

So you want me to split into 3 PRs? Test Discovery, Test Run, Main Run?

jdneo commented 1 month ago

So you want me to split into 3 PRs? Test Discovery, Test Run, Main Run?

Thank you. If you don't mind to do the split, That would be great :)

And I hope the order could be Test Run, Main Run, Test Discovery. Due to that the Test delegation is frequently asked from the community in VS Code Java.