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 3e0d8aabe7..5239e33f65 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 @@ -4,17 +4,17 @@ package net.sourceforge.pmd.lang.java.ast -import io.kotest.core.config.Project -import io.kotest.core.spec.style.DslDrivenSpec +import io.kotest.core.config.configuration +import io.kotest.core.spec.DslDrivenSpec import io.kotest.core.spec.style.scopes.Lifecycle import io.kotest.core.spec.style.scopes.RootScope import io.kotest.core.spec.style.scopes.RootTestRegistration import io.kotest.core.test.TestCaseConfig import io.kotest.core.test.TestContext -import io.kotest.core.test.TestName import io.kotest.core.test.TestType -import io.kotest.runner.junit.platform.IntelliMarker +import io.kotest.core.test.createTestName import net.sourceforge.pmd.lang.ast.test.Assertions +import net.sourceforge.pmd.lang.ast.test.IntelliMarker import io.kotest.matchers.should as kotlintestShould /** @@ -33,11 +33,15 @@ abstract class ParserTestSpec(body: ParserTestSpec.() -> Unit) : DslDrivenSpec() override fun lifecycle(): Lifecycle = Lifecycle.from(this) override fun defaultConfig(): TestCaseConfig = actualDefaultConfig() + override fun defaultTestCaseConfig(): TestCaseConfig? = defaultTestConfig override fun registration(): RootTestRegistration = RootTestRegistration.from(this) + private fun actualDefaultConfig() = + defaultTestConfig ?: defaultTestCaseConfig() ?: configuration.defaultTestConfig + fun test(name: String, disabled: Boolean = false, test: suspend TestContext.() -> Unit) = registration().addTest( - name = TestName(name), + name = createTestName(name), xdisabled = disabled, test = test, config = actualDefaultConfig() @@ -63,7 +67,7 @@ abstract class ParserTestSpec(body: ParserTestSpec.() -> Unit) : DslDrivenSpec() disabled: Boolean = false, spec: suspend GroupTestCtx.() -> Unit) = registration().addContainerTest( - name = TestName(name), + name = createTestName(name), test = { GroupTestCtx(this).spec() }, xdisabled = disabled ) @@ -119,24 +123,20 @@ abstract class ParserTestSpec(body: ParserTestSpec.() -> Unit) : DslDrivenSpec() assertions: ParserTestCtx.() -> Unit) { context.registerTestCase( - name = TestName(name), + name = createTestName(name), test = { ParserTestCtx(javaVersion).assertions() }, config = actualDefaultConfig(), type = TestType.Test ) } - private fun actualDefaultConfig() = - defaultTestConfig ?: defaultTestCaseConfig() - ?: Project.testCaseConfig() - inner class GroupTestCtx(private val context: TestContext) { suspend fun onVersions(javaVersions: List, spec: suspend VersionedTestCtx.() -> Unit) { javaVersions.forEach { javaVersion -> context.registerTestCase( - name = TestName("Java ${javaVersion.pmdName}"), + name = createTestName("Java ${javaVersion.pmdName}"), test = { VersionedTestCtx(this, javaVersion).spec() }, config = actualDefaultConfig(), type = TestType.Container diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index c4c752a486..aaa4f717df 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -13,7 +13,6 @@ net.sourceforge.pmd pmd 6.30.0-SNAPSHOT - ../ @@ -62,32 +61,11 @@ package - - dokka + javadocJar - - org.apache.maven.plugins - maven-jar-plugin - - - kotlin-javadoc - package - - jar - - - ${project.build.directory}/dokka/pmd-lang-test - javadoc - - - - diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/IntelliMarker.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/IntelliMarker.kt new file mode 100644 index 0000000000..d7ad20eea0 --- /dev/null +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/IntelliMarker.kt @@ -0,0 +1,21 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.ast.test + + +import org.junit.jupiter.api.TestFactory +import org.junit.jupiter.api.condition.EnabledIfSystemProperty + +/** + * This is to trick Intellij into making subclasses executable (because of @TestFactory). + * But Junit does not use it because of the unsatisfiable condition. This comes from + * Kotest, but was removed in 4.2.0 without explanation. + */ +interface IntelliMarker { + @EnabledIfSystemProperty(named = "wibble", matches = "wobble") + @TestFactory + fun primer() { + } +} diff --git a/pom.xml b/pom.xml index 2463eb14aa..2804bb2b45 100644 --- a/pom.xml +++ b/pom.xml @@ -85,9 +85,9 @@ ${maven.compiler.test.target} - 1.3.72 - 4.1.2 - 0.10.1 + 1.4.10 + 4.3.0 + 1.4.10.2 5.0