-
Notifications
You must be signed in to change notification settings - Fork 432
sample project that demonstrates how you can test your custom build with a JUnit5 test #1317
base: master
Are you sure you want to change the base?
Conversation
…ogic inside buildSrc with JUnit5 Signed-off-by: Alphonse Bendt <alphonse.bendt@gmail.com>
|
|
||
| tasks.test { | ||
| useJUnitPlatform() | ||
| } |
There was a problem hiding this comment.
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.
}
}
}There was a problem hiding this comment.
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")
}
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Signed-off-by: Alphonse Bendt <alphonse.bendt@gmail.com>
JLLeitschuh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
henrik242
left a comment
There was a problem hiding this 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?
|
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? |
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
developbranch./gradlew check --parallel