Skip to content
This repository was archived by the owner on Aug 19, 2020. It is now read-only.

Conversation

abendt
Copy link

@abendt abendt commented Jan 20, 2019

Context

While learning how to use the Kotlin DSL for Gradle I found the samples to be immensely helpful. However I missed a sample that demonstrated how to unit-test your custom logic in buildSrc with. I think other users also could benefit from some this sample.

#1087

Note: this is a continuation of #1302

Contributor Checklist

  • [x ] Base the PR against the develop branch
  • [x ] Make sure that all commits are signed off to indicate that you agree to the terms of Developer Certificate of Origin.
  • Provide integration tests to verify changes from a user perspective
  • Provide unit tests to verify logic
  • Ensure that tests pass locally: ./gradlew check --parallel

…ogic inside buildSrc with JUnit5

Signed-off-by: Alphonse Bendt <[email protected]>

tasks.test {
useJUnitPlatform()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be more aproprate:

tasks.withType<Test>().configureEach {
    useJunitPlatform()
}

It might also be good to demonstrate configuring Junit 5 as well.

For example:

tasks.withType<Test>().configureEach {
    useJunitPlatform {
        filter {
            // Add an example of configuring some filter here.
        }
    }
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that filter is not JUnit 5 specific and belongs to Test. If i understand it correctly this should be equivalent:

tasks.withType<Test>().configureEach {
    filter {
        // Add an example of configuring some filter here.
     }
}

I'd suggest to use tags instead, to demonstrate a Junit5 specific configuration:

tasks.withType<Test>().configureEach {
    useJUnitPlatform {
        includeTags("fooTag")
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are 100% correct. Good catch.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i have changed it

Copy link
Contributor

@JLLeitschuh JLLeitschuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@eskatos eskatos changed the base branch from develop to master April 25, 2019 14:01
Copy link

@henrik242 henrik242 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Any reason why this hasn't been merged?

@alexvas
Copy link

alexvas commented Nov 4, 2019

The example is great! My only question is: why should I google is out as a PR instead of one of official Kotlin DSL samples?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants