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 gradle test sourcesets not supported when running tests #4720

Closed
merscwog opened this issue Oct 2, 2022 · 0 comments · Fixed by #4721
Closed

Custom gradle test sourcesets not supported when running tests #4720

merscwog opened this issue Oct 2, 2022 · 0 comments · Fixed by #4721
Labels
Gradle [ci] enable "build tools" tests kind:bug Bug report or fix

Comments

@merscwog
Copy link
Contributor

merscwog commented Oct 2, 2022

Apache NetBeans version

Apache NetBeans 15

What happened

Netbeans 15 properly detects all gradle test sourcesets and code within them, but when attempting to run or debug any tests other than those within the default test sourceset ("test"), they fail, because currently the run/debug actions are hard coded to the cleanTest and test tasks, when it should be clean[NameOfTestSourceSet] and [nameOfTestSourceSet] for all sourceset (which includes the default test sourceset "test").

How to reproduce

  1. git clone https://github.com/merscwog/gradleproject1.git
  2. Start up NetBeans 15
  3. File... Open Project... (Ctrl+Shift+O)
  4. Try to run or debug the 'appHasAGreeting()' test method in the IntegAppTest.java file and it should fail (Green arrow)

The actual gradle command contains this: "check cleanIntegTest integTest --tests gradleproject1.IntegAppTest.appHasAGreeting", but IntegAppTest is not in the test (default) sourceset, so it will complain that it cannot find the method to run.

Manual steps to create the referenced repo:

  1. Start up NetBeans 15
  2. File... New Project... (Ctrl+Shift+N)
  3. Select Java with Gradle
  4. Select Java Application
  5. Press [Next] button
  6. Leave as default or put something sensible in for project name and location, then Press [Finish] button
  7. Open the new project (if not already opened)
  8. Edit the app/build.gradle file and apply the 'jvm-test-suite' plugin and add a new integTest JvmTestSuite
plugins {
    id 'jvm-test-suite'
}

testing {
    suites {
        test {
            useJUnitJupiter()
        }

        integTest(JvmTestSuite) {
            dependencies {
                implementation project
            }
        }
    }
}

9, Copy AppTest.java into a new file into app/src/integTest/java/gradleproject1/IntegAppTest.java (and fix the classname)
10. Try to run or debug the 'appHasAGreeting()' test method in the IntegAppTest.java file and it should fail (Green arrow)

Custom test sourcesets have been possible in Gradle for almost a decade now, but the above is the quickest way to highlight the issue with NetBeans 15 and the version of Gradle that it defaults to (Gradle 7.5).

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows and Linux

JDK

OpenJDK Java 11/17

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

Yes

Code of Conduct

Yes

@merscwog merscwog added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Oct 2, 2022
@mbien mbien added Gradle [ci] enable "build tools" tests and removed needs:triage Requires attention from one of the committers labels Oct 3, 2022
@mbien mbien linked a pull request Oct 3, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gradle [ci] enable "build tools" tests kind:bug Bug report or fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants