From 68ae318f028b49f1922c23975fbefe2c5d59f141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 20 Jul 2020 00:12:40 +0200 Subject: [PATCH] Update to kotest --- pmd-java/pom.xml | 9 ++----- .../lang/java/ast/ASTCatchStatementTest.kt | 6 ++--- .../pmd/lang/java/ast/Java11Test.kt | 4 +-- .../pmd/lang/java/ast/KotlinTestingDsl.kt | 8 +++--- .../pmd/lang/java/ast/ParserTestSpec.kt | 10 ++++--- .../lang/java/ast/SwitchExpressionTests.kt | 2 +- .../pmd/lang/java/ast/WildcardBoundsTest.kt | 2 +- pmd-lang-test/pom.xml | 10 +++++-- .../pmd/cpd/test/CpdTextComparisonTest.kt | 2 +- .../pmd/lang/ast/test/AstMatcherDslAdapter.kt | 6 ++--- .../pmd/lang/ast/test/TestUtils.kt | 6 ++--- pmd-modelica/pom.xml | 9 ++----- .../lang/modelica/ast/ModelicaCoordsTest.kt | 6 ++--- pmd-scala-modules/pmd-scala-common/pom.xml | 9 ++----- .../pmd/lang/scala/ast/ScalaTreeTests.kt | 4 +-- pom.xml | 27 +++++++++++-------- 16 files changed, 59 insertions(+), 61 deletions(-) diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index f3e4264c30..5b84ecba96 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -172,13 +172,8 @@ test - io.kotlintest - kotlintest-assertions - test - - - io.kotlintest - kotlintest-core + io.kotest + kotest-assertions-core-jvm test diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTCatchStatementTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTCatchStatementTest.kt index 8c4d34181f..f6534b1415 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTCatchStatementTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTCatchStatementTest.kt @@ -1,8 +1,8 @@ package net.sourceforge.pmd.lang.java.ast -import io.kotlintest.matchers.collections.shouldContainExactly -import io.kotlintest.should -import io.kotlintest.shouldBe +import io.kotest.matchers.collections.shouldContainExactly +import io.kotest.matchers.should +import io.kotest.matchers.shouldBe import net.sourceforge.pmd.lang.java.ast.JavaVersion.* import net.sourceforge.pmd.lang.java.ast.JavaVersion.Companion.Earliest import net.sourceforge.pmd.lang.java.ast.JavaVersion.Companion.Latest diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt index 110b01c3e1..4f7e3fa53d 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt @@ -1,5 +1,5 @@ -import io.kotlintest.shouldBe +import io.kotest.matchers.shouldBe import net.sourceforge.pmd.lang.java.ast.* import net.sourceforge.pmd.lang.java.ast.JavaVersion.* import net.sourceforge.pmd.lang.java.ast.JavaVersion.Companion.Latest @@ -88,4 +88,4 @@ class Java11Test : ParserTestSpec({ } } -}) \ No newline at end of file +}) diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt index dc34b3db28..e3401c2c37 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt @@ -1,7 +1,7 @@ package net.sourceforge.pmd.lang.java.ast -import io.kotlintest.matchers.string.shouldContain -import io.kotlintest.shouldThrow +import io.kotest.assertions.throwables.shouldThrow +import io.kotest.matchers.string.shouldContain import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.ast.test.Assertions import net.sourceforge.pmd.lang.ast.test.NodeSpec @@ -56,7 +56,7 @@ enum class JavaVersion : Comparable { * * These are implicitly used by [matchExpr] and [matchStmt], which specify a matcher directly * on the strings, using their type parameter and the info in this test context to parse, find - * the node, and execute the matcher in a single call. These may be used by [io.kotlintest.should], + * the node, and execute the matcher in a single call. These may be used by [io.kotest.matchers.should], * e.g. * * parserTest("Test ShiftExpression operator") { @@ -69,7 +69,7 @@ enum class JavaVersion : Comparable { * Import statements in the parsing contexts can be configured by adding types to [importedTypes], * or strings to [otherImports]. * - * Technically the utilities provided by this class may be used outside of [io.kotlintest.specs.FunSpec]s, + * Technically the utilities provided by this class may be used outside of [io.kotest.specs.FunSpec]s, * e.g. in regular JUnit tests, but I think we should strive to uniformize our testing style, * especially since KotlinTest defines so many. * diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ParserTestSpec.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ParserTestSpec.kt index 741b2bff65..dc65e36790 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ParserTestSpec.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ParserTestSpec.kt @@ -1,10 +1,12 @@ package net.sourceforge.pmd.lang.java.ast -import io.kotlintest.AbstractSpec -import io.kotlintest.TestContext -import io.kotlintest.TestType +import io.kotest.core.config.Project +import io.kotest.core.spec.style.DslDrivenSpec +import io.kotest.core.test.TestContext +import io.kotest.core.test.TestName +import io.kotest.core.test.TestType import net.sourceforge.pmd.lang.ast.test.Assertions -import io.kotlintest.should as kotlintestShould +import io.kotest.matchers.should as kotlintestShould /** * Base class for grammar tests that use the DSL. Tests are layered into diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/SwitchExpressionTests.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/SwitchExpressionTests.kt index 4dd28b2bb2..7455d07bc8 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/SwitchExpressionTests.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/SwitchExpressionTests.kt @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.java.ast -import io.kotlintest.shouldBe +import io.kotest.matchers.shouldBe /** * @author Clément Fournier diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/WildcardBoundsTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/WildcardBoundsTest.kt index b62a9ac638..c5f174e2f7 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/WildcardBoundsTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/WildcardBoundsTest.kt @@ -1,6 +1,6 @@ package net.sourceforge.pmd.lang.java.ast -import io.kotlintest.shouldBe +import io.kotest.matchers.shouldBe class WildcardBoundsTest : ParserTestSpec({ diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index 6fa4a14da8..0ffd937ce3 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -105,8 +105,14 @@ of the pmd-lang-test module --> - io.kotlintest - kotlintest-assertions + io.kotest + kotest-assertions-core-jvm + compile + + + + io.kotest + kotest-runner-junit5-jvm compile diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/cpd/test/CpdTextComparisonTest.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/cpd/test/CpdTextComparisonTest.kt index 2b198984cd..8335f58b12 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/cpd/test/CpdTextComparisonTest.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/cpd/test/CpdTextComparisonTest.kt @@ -4,7 +4,7 @@ package net.sourceforge.pmd.cpd.test -import io.kotlintest.shouldThrow +import io.kotest.assertions.throwables.shouldThrow import net.sourceforge.pmd.cpd.SourceCode import net.sourceforge.pmd.cpd.TokenEntry import net.sourceforge.pmd.cpd.Tokenizer diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/AstMatcherDslAdapter.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/AstMatcherDslAdapter.kt index 419fafabff..3d90212be9 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/AstMatcherDslAdapter.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/AstMatcherDslAdapter.kt @@ -26,7 +26,7 @@ object NodeTreeLikeAdapter : DoublyLinkedTreeLikeAdapter { /** A subtree matcher written in the DSL documented on [TreeNodeWrapper]. */ typealias NodeSpec = TreeNodeWrapper.() -> Unit -/** A function feedable to [io.kotlintest.should], which fails the test if an [AssertionError] is thrown. */ +/** A function feedable to [io.kotest.matchers.should], which fails the test if an [AssertionError] is thrown. */ typealias Assertions = (M) -> Unit /** A shorthand for [baseShouldMatchSubtree] providing the [NodeTreeLikeAdapter]. */ @@ -37,7 +37,7 @@ inline fun Node?.shouldMatchNode(ignoreChildren: Boolean = fa /** * Returns [an assertion function][Assertions] asserting that its parameter conforms to the given [NodeSpec]. * - * Use it with [io.kotlintest.should], e.g. `node should matchNode {}`. + * Use it with [io.kotest.matchers.should], e.g. `node should matchNode {}`. * * See also the samples on [TreeNodeWrapper]. * @@ -50,7 +50,7 @@ inline fun Node?.shouldMatchNode(ignoreChildren: Boolean = fa * Assertions may consist of [NWrapper.child] calls, which perform the same type of node * matching on a child of the tested node. * - * @return A matcher for AST nodes, suitable for use by [io.kotlintest.should]. + * @return A matcher for AST nodes, suitable for use by [io.kotest.matchers.should]. */ inline fun matchNode(ignoreChildren: Boolean = false, noinline nodeSpec: NodeSpec) : Assertions = { it.shouldMatchNode(ignoreChildren, nodeSpec) } diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt index 779308632c..47dba9b1d4 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.ast.test -import io.kotlintest.should +import io.kotest.matchers.should import kotlin.reflect.KCallable import kotlin.reflect.jvm.isAccessible -import io.kotlintest.shouldBe as ktShouldBe +import io.kotest.matchers.shouldBe as ktShouldBe /** * Extension to add the name of a property to error messages. @@ -48,7 +48,7 @@ private fun assertWrapper(callable: KCallable, right: V, asserter: (N, * have to use the name of the getter instead of that of the generated * property (with the get prefix). * - * If this conflicts with [io.kotlintest.shouldBe], use the equivalent [shouldEqual] + * If this conflicts with [io.kotest.matchers.shouldBe], use the equivalent [shouldEqual] * */ infix fun KCallable.shouldBe(expected: V?) = this.shouldEqual(expected) diff --git a/pmd-modelica/pom.xml b/pmd-modelica/pom.xml index 3c3f5de689..15ccca423b 100644 --- a/pmd-modelica/pom.xml +++ b/pmd-modelica/pom.xml @@ -120,13 +120,8 @@ test - io.kotlintest - kotlintest-assertions - test - - - io.kotlintest - kotlintest-core + io.kotest + kotest-assertions-core-jvm test diff --git a/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt b/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt index dfa62e29b5..7cc7f3855c 100644 --- a/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt +++ b/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt @@ -4,9 +4,9 @@ package net.sourceforge.pmd.lang.modelica.ast -import io.kotlintest.should -import io.kotlintest.shouldBe -import io.kotlintest.specs.AbstractFunSpec +import io.kotest.matchers.should +import io.kotest.matchers.shouldBe +import io.kotest.specs.AbstractFunSpec import net.sourceforge.pmd.lang.LanguageRegistry import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.ast.test.matchNode diff --git a/pmd-scala-modules/pmd-scala-common/pom.xml b/pmd-scala-modules/pmd-scala-common/pom.xml index 4304adf8c6..e7c639d0df 100644 --- a/pmd-scala-modules/pmd-scala-common/pom.xml +++ b/pmd-scala-modules/pmd-scala-common/pom.xml @@ -140,13 +140,8 @@ test - io.kotlintest - kotlintest-assertions - test - - - io.kotlintest - kotlintest-core + io.kotest + kotest-assertions-core-jvm test diff --git a/pmd-scala-modules/pmd-scala-common/src/test/kotlin/net/sourceforge/pmd/lang/scala/ast/ScalaTreeTests.kt b/pmd-scala-modules/pmd-scala-common/src/test/kotlin/net/sourceforge/pmd/lang/scala/ast/ScalaTreeTests.kt index 32d808af26..5b18e1d8e5 100644 --- a/pmd-scala-modules/pmd-scala-common/src/test/kotlin/net/sourceforge/pmd/lang/scala/ast/ScalaTreeTests.kt +++ b/pmd-scala-modules/pmd-scala-common/src/test/kotlin/net/sourceforge/pmd/lang/scala/ast/ScalaTreeTests.kt @@ -4,8 +4,8 @@ package net.sourceforge.pmd.lang.scala.ast -import io.kotlintest.should -import io.kotlintest.specs.AbstractFunSpec +import io.kotest.matchers.should +import io.kotest.specs.AbstractFunSpec import net.sourceforge.pmd.lang.LanguageRegistry import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.ast.test.matchNode diff --git a/pom.xml b/pom.xml index 4e0026061d..539d5e7174 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ ${maven.compiler.test.target} 1.3.0 - 3.1.8 + 4.1.2 0.10.1 @@ -269,9 +269,9 @@ - io.kotlintest - kotlintest-runner-junit5 - ${kotlintest.version} + io.kotest + kotest-runner-junit5-jvm + ${kotest.version} @@ -826,17 +826,22 @@ ${kotlin.version} test - - io.kotlintest - kotlintest-assertions - ${kotlintest.version} + io.kotest + kotest-runner-junit5-jvm + ${kotest.version} test - io.kotlintest - kotlintest-core - ${kotlintest.version} + io.kotest + kotest-assertions-core-jvm + ${kotest.version} + test + + + io.kotest + kotest-property-jvm + ${kotest.version} test