Skip to content

Commit 8c92f9b

Browse files
committed
Move all tests to use Junit 5
1 parent 6cb6626 commit 8c92f9b

File tree

4 files changed

+50
-23
lines changed

4 files changed

+50
-23
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ local.properties
8585
## Plugin-specific files:
8686

8787
# IntelliJ
88-
/out/
88+
*/out/
8989

9090
# mpeltonen/sbt-idea plugin
9191
.idea_modules/
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package org.jlleitschuh.guice
22

3-
import io.kotlintest.matchers.shouldBe
4-
import io.kotlintest.specs.StringSpec
3+
import org.junit.jupiter.api.Assertions.assertEquals
4+
import org.junit.jupiter.api.Test
55

66

7-
class TypeLiteralTest : StringSpec() {
8-
init {
9-
"should keep type data" {
10-
val keySetType = typeLiteral<Map<Int, String>>().getReturnType(Map::class.java.getMethod("keySet"))
11-
keySetType.toString() shouldBe "java.util.Set<java.lang.Integer>"
12-
}
7+
class TypeLiteralTest {
8+
9+
@Test
10+
fun `should keep type data`() {
11+
val keySetType = typeLiteral<Map<Int, String>>().getReturnType(Map::class.java.getMethod("keySet"))
12+
assertEquals("java.util.Set<java.lang.Integer>", keySetType.toString())
1313
}
1414
}

kotlin-guiced.gradle.kts

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import org.gradle.api.publish.maven.MavenPublication
22
import org.gradle.api.tasks.bundling.Jar
33
import org.gradle.api.tasks.wrapper.Wrapper
4+
import org.junit.platform.console.options.Details
45

56
buildscript {
67
repositories {
@@ -13,6 +14,7 @@ buildscript {
1314
dependencies {
1415
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.1")
1516
classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3")
17+
classpath("org.junit.platform:junit-platform-gradle-plugin:1.1.0-M1")
1618
}
1719
}
1820
apply {
@@ -33,6 +35,7 @@ subprojects {
3335
plugin("kotlin")
3436
plugin("maven-publish")
3537
plugin("java-library")
38+
plugin("org.junit.platform.gradle.plugin")
3639
}
3740

3841
val publicationName = "publication-$name"
@@ -58,7 +61,19 @@ subprojects {
5861
dependencies {
5962
"compile"(kotlin("stdlib"))
6063
"compile"(kotlin("reflect"))
61-
"testCompile"(create(group = "io.kotlintest", name = "kotlintest", version = "2.0.2"))
64+
65+
"testCompile"(junitJupiter("junit-jupiter-api"))
66+
"testCompile"(junitJupiter("junit-jupiter-params"))
67+
"testRuntime"(junitJupiter("junit-jupiter-engine"))
68+
"testRuntime"(create(group = "org.junit.platform", name = "junit-platform-launcher", version = "1.1.0-M1"))
69+
}
70+
71+
junitPlatform {
72+
details = Details.VERBOSE
73+
74+
filters {
75+
includeClassNamePatterns(".*Test", ".*Tests", ".*Spec")
76+
}
6277
}
6378

6479
val sourceJarTask = task<Jar>("sourceJar") {
@@ -87,6 +102,15 @@ task<Wrapper>("wrapper") {
87102
distributionType = Wrapper.DistributionType.ALL
88103
}
89104

105+
fun DependencyHandler.junitJupiter(name: String) =
106+
create(group = "org.junit.jupiter", name = name, version = "5.1.0-M1")
107+
108+
/**
109+
* Configures the [junitPlatform][org.junit.platform.gradle.plugin.JUnitPlatformExtension] project extension.
110+
*/
111+
fun Project.`junitPlatform`(configure: org.junit.platform.gradle.plugin.JUnitPlatformExtension.() -> Unit) =
112+
extensions.configure("junitPlatform", configure)
113+
90114
/**
91115
* Retrieves or configures the [bintray][com.jfrog.bintray.gradle.BintrayExtension] project extension.
92116
*/

multibindings/src/test/kotlin/org/jlleitschuh/guice/multibindings/MultibinderTest.kt

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
package org.jlleitschuh.guice.multibindings
22

33
import com.google.inject.AbstractModule
4-
import io.kotlintest.specs.StringSpec
4+
import org.junit.jupiter.api.Test
55

6-
class MultibinderTest : StringSpec() {
6+
class MultibinderTest {
77
@Target(AnnotationTarget.CLASS)
88
@Retention(AnnotationRetention.RUNTIME)
99
annotation class TestAnnotation
10+
1011
interface TestInterface
11-
init {
12-
"should be able to bind an interface" {
13-
object : AbstractModule() {
14-
override fun configure() {
15-
KotlinMultibinder.newSetBinder<TestInterface>(binder())
16-
}
12+
13+
@Test
14+
fun `should be able to bind an interface`() {
15+
object : AbstractModule() {
16+
override fun configure() {
17+
KotlinMultibinder.newSetBinder<TestInterface>(binder())
1718
}
1819
}
19-
"should be able to bind an interface and an annotation" {
20-
object : AbstractModule() {
21-
override fun configure() {
22-
KotlinMultibinder.newSetBinder<TestInterface>(binder(), TestAnnotation::class)
23-
}
20+
}
21+
22+
@Test
23+
fun `should be able to bind an interface and an annotation`() {
24+
object : AbstractModule() {
25+
override fun configure() {
26+
KotlinMultibinder.newSetBinder<TestInterface>(binder(), TestAnnotation::class)
2427
}
2528
}
2629
}

0 commit comments

Comments
 (0)