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

Custom test reporting #28709

Open
aSemy opened this issue Apr 6, 2024 · 1 comment
Open

Custom test reporting #28709

aSemy opened this issue Apr 6, 2024 · 1 comment
Labels
a:feature A new functionality in:testing

Comments

@aSemy
Copy link
Contributor

aSemy commented Apr 6, 2024

Expected Behavior

I would like to be able to report test results directly to Gradle from within a custom Gradle task.

I want the reported tests to be visible in the Gradle test report, correctly reported when the tests are launched in IntelliJ, and visible in CI tools (like GitHub actions).

Current Behavior (optional)

There is no official way to report test results directly to Gradle. There is no workaround.

TestResultProcessor is internal.

Because tests can't be reported to Gradle, this means that other tools that rely on Gradle's reporting can't pick up the custom tests.

  • IntelliJ can't display the test results, which is normally very useful and allows for utils like 'click to show difference'.
  • Custom tests can't be reported in CI tools, like GitHub.
  • Custom tests are missing from reports, metrics, stats.

Context

Here are some examples of when I want to report tests to Gradle:

  1. I want to Kotest to support nested JavaScript tests. Currently this is not possible, because of limitations in the JavaScript testing frameworks (they do not support dynamically created nested tests). Because Kotest cannot directly report test results to Gradle, it looks like support might not even be possible.

  2. I want to write a quick verification task. I want this to be reported to Gradle as a test.

    val checkReadme by tasks.registering {
        group = "verification"
    
        val readme = file("readme.md")
    
        val projectVersion = project.version.toString()
    
        doLast {
            require("Current project version is $projectVersion" in readme.readText()) {
                "Incorrect project version in readme"
            }
        }
    }
  3. I want BCV validation results to be reported as tests.

  4. Because Gradle doesn't fully support JUnit features (see footnote 1), I want to run the tests manually using the JUnit console launcher, and report the results to Gradle. Example.

  5. I want to use a non-JVM testing framework, like Jasmine, Web Test Runner, Cucumber.

Custom JUnit TestEngine

In theory, one could write a custom JUnit TestEngine to launch custom tests, but this is a prohibitive amount of work, especially for the simpler cases where I just want to report a single test case.

A custom TestEngine would also introduce a lot of extra complexity and layers, and potentially a new language for the non-JVM based tests. Even if using a custom TestEngine, Gradle doesn't fully support JUnit Platform (footnote 1), so this would be a non-starter.

Even if using a custom JUnit TestEngine, Gradle unnecessarily requires that the input property testClassesDirs of a Test task has .class files, even if not testing JVM tests!

Related


Footnote 1: Here are the issues related to Gradle not fully supporting JUnit

@aSemy aSemy added a:feature A new functionality to-triage labels Apr 6, 2024
@ov7a
Copy link
Member

ov7a commented Apr 8, 2024

This feature request is in the backlog of the relevant team and is prioritized by them.

@ov7a ov7a added in:testing and removed to-triage labels Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:testing
Projects
None yet
Development

No branches or pull requests

2 participants