Junit5: Support tag-specific Gradle tasks

Created on 1 Dec 2016  Â·  6Comments  Â·  Source: junit-team/junit5

_(This is a question I asked on StackOverflow – I am filing this issue as requested by @sbrannen)_

I use the following annotation to tag my integration tests:

@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("integration-test")
public @interface IntegrationTest {
}

This is the filter I use in build.gradle to exclude these tests from gradle build:

junitPlatform {
    filters {
        tags {
            exclude 'integration-test'
        }
    }
}

So far, so good.

Now I would like to offer a Gradle task which specifically runs my integration tests – what's the recommended approach?

Gradle enhancement

Most helpful comment

This enhancement would be hardly preferred! Is there any plan for this in the near future?

In fact the given workaround is not a real solution for what i need. I would like to execute e.g. just all integration-tests of a project and nothing more. But I need the opportunity to run all other tests with the normal test as well. With this workaround I can only run all, or just the normal tests, not the other way round.

All 6 comments

See workaround on Stack Overflow: http://stackoverflow.com/a/40912322/388980

This enhancement would be hardly preferred! Is there any plan for this in the near future?

In fact the given workaround is not a real solution for what i need. I would like to execute e.g. just all integration-tests of a project and nothing more. But I need the opportunity to run all other tests with the normal test as well. With this workaround I can only run all, or just the normal tests, not the other way round.

Has anything changed since the request of this feature?
A custom configuration for tasks to execute specific tests with give tags is highly preferred. Any update on this subject?

No, there is no update on this issue.

At this point in time, we are working with the Gradle team to move the JUnit Platform Gradle plugin to Gradle.

We are therefore not planning on implementing any major new features in the plugin provided by the JUnit Team for the time being.

In fact the given workaround is not a real solution for what i need. I would like to execute e.g. just all integration-tests of a project and nothing more. But I need the opportunity to run all other tests with the normal test as well. With this workaround I can only run all, or just the normal tests, not the other way round.

You should be able to _tweak_ the workaround to achieve your goals.

Just declare the included or excluded tags within an if-block instead of inline as in the Stack Overflow answer.

Since Gradle now provides native support for running tests on the JUnit Platform, we've decided to deprecate our custom plugin (see #1317 for details). Thus, we'll not add any new features to it.

Was this page helpful?
0 / 5 - 0 ratings