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

Support tag-specific junit5 tasks #6172

Closed
jcornaz opened this issue Aug 2, 2018 · 4 comments

Comments

@jcornaz
Copy link

@jcornaz jcornaz commented Aug 2, 2018

Since gradle provide native support of the Junit5 platform, the JUnit team dropped support of their plugin. So the feature request Support tag-specific Gradle tasks will not be implemented by the Junit team.

Expected Behavior

User should be able to create tag-specific tasks. Here is an example:

task uiTest(type: Junit5Test) {
  includeTags = ['ui']
  excludeTags = ['integration']
}

Current Behavior

Currently, user has to write a filter in the Juni5 configuration, using condition based on properties. Here is an example (comming from this StackOverflow question):

junitPlatform {
    filters {
        tags {
            exclude project.hasProperty('runIntegrationTests') ? '' : 'integration-test'
        }
    }
}

Context

In my gradle build to be able to provide the following tasks:

  • test run only unit tests
  • integrationTest run integration tests
  • uiTest run the UI test
  • check (used by the build system) run all tests

And I would like to be easy and safe to modify/add such tasks

Your Environment

Gradle 4.9
Junit 5.2.0
Java 8+
Kotlin 1.2+

@oehme

This comment has been minimized.

Copy link
Member

@oehme oehme commented Aug 2, 2018

This is already possible, the useJunitPlatform method is on the Test task, so just create an additional Test task.

@oehme oehme closed this Aug 2, 2018
@jcornaz

This comment has been minimized.

Copy link
Author

@jcornaz jcornaz commented Aug 2, 2018

Ok thanks @oehme. Is that written somewhere in the documentation? I lost many hours looking for this feature.

@oehme

This comment has been minimized.

Copy link
Member

@oehme oehme commented Aug 2, 2018

It's in the testing chapter

@TWiStErRob

This comment has been minimized.

Copy link
Contributor

@TWiStErRob TWiStErRob commented Sep 9, 2018

For posterity: the syntax for this in Gradle 4.6+ (with just a java plugin) is:

task uiTest(type: Test) {
    useJUnitPlatform {
        includeTags 'ui'
        excludeTags 'integration'
    }
}

See https://stackoverflow.com/a/52245028/253468 for more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.