You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add more location information to Test messages #674
For JUnit tests (JVM languages) there seems to be no feedback from the library about file location of the test. Instead there is suite, class, method. But there is no way of communicating this info to the BSP client.
There is also no option in TestFinish to passback a stacktrace which is helpful to diagnose test failures.
What do you propose
I'd like to propose a JVMTestStartType that can be added to TestStart#data and JVMTestFinishType to be added to TestFinish#data. TestStart currently doesn't have a dataKind or data member and would need to be added.
Both JVMTestStartType and JVMTestFinishType would contain suite, class, method and JVMTestFinishType would also contain stacktrace.
I've called the types JVMTestXXXType but I'm not sure whether this as applicable to all test frameworks or all JVM test frameworks or a subset of JVM test frameworks.
Here's some JVM examples... Junit seems to pass back method, package, class, file (with optional position). TestNG seems to pass back class, method, method parameters. Gradle passes back suite, class, method for JUnit and TestNG SBT test Interface appears to pass back the FQN of suite/method
The idea of parameterized tests is a bit hazy. The file location, suite, class, method should be the same regardless of the parameters used to run the test but I guess it's possible there are overloaded methods of the same name with different parameter types in the file which would mean the BSP client would not know which method was run from the above new data structures. I feel it's unlikely but 🤷.
I've checked to make sure there isn't already a way to support this in the current protocol
I've checked the existing protocol and there isn't a way to do this currently
Vote for this. class/method/suite name can be optional fields.
The idea of parameterized tests is a bit hazy. The file location, suite, class, method should be the same regardless of the parameters used to run the test
At least for JUnit 5 running with Gradle, each execution of the parameterized tests will be appended by a sequence number. For example, running:
Just to document what we ended up with in the Gradle BSP, this custom solution seemed to cope with all the cases we came up with...
classTestStartExextendsTestStart { // extends from ch.epfl.scala.bsp4j.TestStartTestNametestName// custom test definition
}
classTestFinishExextendsTestFinish { // extends from ch.epfl.scala.bsp4j.TestFinishTestNametestName// custom test definitionStringstackTrace// stacktrace for errors isn't in the current spec
}
classTestName {
StringdisplayNameStringsuiteNameStringclassNameStringmethodNameTestNameparent
}
The recursive nature of TestName copes with JUnit's @Nested that allows inner classes to defined tests. It also copes with DynamicContainer that allows nesting of tests as deep as you like.
Another option was putting TestName and stackTrace in the data: TestFinishData field of TestFinish but TestStart lacks any data: ??? field.
The is purely for handling buildTarget/test. Ideally test discovery buildTarget/scalaTestClasses and buildTarget/jvmTestEnvironment would return tests at a level other than Class, e.g. Method, to allow the BSP client to discover and run a single method.
Activity
jdneo commentedon Jun 2, 2024
Vote for this. class/method/suite name can be optional fields.
At least for JUnit 5 running with Gradle, each execution of the parameterized tests will be appended by a sequence number. For example, running:
will get
as the method name.
Arthurm1 commentedon Mar 4, 2025
Just to document what we ended up with in the Gradle BSP, this custom solution seemed to cope with all the cases we came up with...
The recursive nature of
TestNamecopes with JUnit's @Nested that allows inner classes to defined tests. It also copes with DynamicContainer that allows nesting of tests as deep as you like.Another option was putting
TestNameandstackTracein thedata: TestFinishDatafield ofTestFinishbutTestStartlacks anydata: ???field.The is purely for handling
buildTarget/test. Ideally test discoverybuildTarget/scalaTestClassesandbuildTarget/jvmTestEnvironmentwould return tests at a level other thanClass, e.g.Method, to allow the BSP client to discover and run a single method.