diff --git a/detekt-rules-documentation/build.gradle.kts b/detekt-rules-documentation/build.gradle.kts index 78e6820b88b..e0469ce857e 100644 --- a/detekt-rules-documentation/build.gradle.kts +++ b/detekt-rules-documentation/build.gradle.kts @@ -5,6 +5,5 @@ plugins { dependencies { compileOnly(projects.detektApi) testImplementation(projects.detektTest) - testImplementation(libs.bundles.testImplementation) - testRuntimeOnly(libs.spek.runner) + testImplementation(libs.assertj) } diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/AbsentOrWrongFileLicenseSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/AbsentOrWrongFileLicenseSpec.kt index e8cf85e3cc3..debff31665a 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/AbsentOrWrongFileLicenseSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/AbsentOrWrongFileLicenseSpec.kt @@ -11,18 +11,21 @@ import io.gitlab.arturbosch.detekt.test.assertThat import io.gitlab.arturbosch.detekt.test.lint import io.gitlab.arturbosch.detekt.test.yamlConfig import org.jetbrains.kotlin.resolve.BindingContext -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test import java.io.PrintStream import java.net.URI -internal class AbsentOrWrongFileLicenseSpec : Spek({ +class AbsentOrWrongFileLicenseSpec { - describe("AbsentOrWrongFileLicense rule") { + @Nested + inner class `AbsentOrWrongFileLicense rule` { - context("file with correct license header") { + @Nested + inner class `file with correct license header` { - it("reports nothing") { + @Test + fun `reports nothing`() { val findings = checkLicence( """ /* LICENSE */ @@ -34,9 +37,11 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ } } - context("file with incorrect license header") { + @Nested + inner class `file with incorrect license header` { - it("reports missed license header") { + @Test + fun `reports missed license header`() { val findings = checkLicence( """ /* WRONG LICENSE */ @@ -48,9 +53,11 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ } } - context("file with absent license header") { + @Nested + inner class `file with absent license header` { - it("reports missed license header") { + @Test + fun `reports missed license header`() { val findings = checkLicence( """ package cases @@ -61,9 +68,11 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ } } - context("file with correct license header using regex matching") { + @Nested + inner class `file with correct license header using regex matching` { - it("reports nothing for 2016") { + @Test + fun `reports nothing for 2016`() { val findings = checkLicence( """ // @@ -80,7 +89,8 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ assertThat(findings).isEmpty() } - it("reports nothing for 2021") { + @Test + fun `reports nothing for 2021`() { val findings = checkLicence( """ // @@ -98,9 +108,11 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ } } - context("file with incorrect license header using regex matching") { + @Nested + inner class `file with incorrect license header using regex matching` { - it("file with missing license header") { + @Test + fun `file with missing license header`() { val findings = checkLicence( """ package cases @@ -111,7 +123,8 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ assertThat(findings).hasSize(1) } - it("file with license header not on the first line") { + @Test + fun `file with license header not on the first line`() { val findings = checkLicence( """ package cases @@ -128,7 +141,8 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ assertThat(findings).hasSize(1) } - it("file with incomplete license header") { + @Test + fun `file with incomplete license header`() { val findings = checkLicence( """ // @@ -142,7 +156,8 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ assertThat(findings).hasSize(1) } - it("file with too many empty likes in license header") { + @Test + fun `file with too many empty likes in license header`() { val findings = checkLicence( """ // @@ -160,7 +175,8 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ assertThat(findings).hasSize(1) } - it("file with incorrect year in license header") { + @Test + fun `file with incorrect year in license header`() { val findings = checkLicence( """ // @@ -178,7 +194,7 @@ internal class AbsentOrWrongFileLicenseSpec : Spek({ } } } -}) +} @OptIn(UnstableApi::class) private fun checkLicence(content: String, isRegexLicense: Boolean = false): List { diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivateMethodSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivateMethodSpec.kt index a92d60d66c8..ad011a5736b 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivateMethodSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivateMethodSpec.kt @@ -2,15 +2,17 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.compileAndLint import org.assertj.core.api.Assertions.assertThat -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test -class CommentOverPrivateMethodSpec : Spek({ - val subject by memoized { CommentOverPrivateFunction() } +class CommentOverPrivateMethodSpec { + val subject = CommentOverPrivateFunction() - describe("CommentOverPrivateFunction rule") { + @Nested + inner class `CommentOverPrivateFunction rule` { - it("reports private method with a comment") { + @Test + fun `reports private method with a comment`() { val code = """ class Test { /** @@ -21,7 +23,8 @@ class CommentOverPrivateMethodSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("does not report public method with a comment") { + @Test + fun `does not report public method with a comment`() { val code = """ /** * asdf @@ -30,7 +33,8 @@ class CommentOverPrivateMethodSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report public method in a class with a comment") { + @Test + fun `does not report public method in a class with a comment`() { val code = """ class Test { /** @@ -41,4 +45,4 @@ class CommentOverPrivateMethodSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } } -}) +} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivatePropertiesSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivatePropertiesSpec.kt index 7d16c3a17f2..efe352ab7fc 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivatePropertiesSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivatePropertiesSpec.kt @@ -2,15 +2,17 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.compileAndLint import org.assertj.core.api.Assertions.assertThat -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test -class CommentOverPrivatePropertiesSpec : Spek({ - val subject by memoized { CommentOverPrivateProperty() } +class CommentOverPrivatePropertiesSpec { + val subject = CommentOverPrivateProperty() - describe("CommentOverPrivateProperty rule") { + @Nested + inner class `CommentOverPrivateProperty rule` { - it("reports private property with a comment") { + @Test + fun `reports private property with a comment`() { val code = """ /** * asdf @@ -19,7 +21,8 @@ class CommentOverPrivatePropertiesSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("does not report public property with a comment") { + @Test + fun `does not report public property with a comment`() { val code = """ /** * asdf @@ -28,7 +31,8 @@ class CommentOverPrivatePropertiesSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("reports private property in class with a comment") { + @Test + fun `reports private property in class with a comment`() { val code = """ class Test { /** @@ -39,7 +43,8 @@ class CommentOverPrivatePropertiesSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("does not report public property with a comment") { + @Test + fun `does not report public property in class with a comment`() { val code = """ class Test { /** @@ -50,4 +55,4 @@ class CommentOverPrivatePropertiesSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } } -}) +} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/DeprecatedBlockTagSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/DeprecatedBlockTagSpec.kt index 42c2feca700..e04d689bacc 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/DeprecatedBlockTagSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/DeprecatedBlockTagSpec.kt @@ -2,13 +2,16 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.assertThat import io.gitlab.arturbosch.detekt.test.compileAndLint -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test -class DeprecatedBlockTagSpec : Spek({ - val subject by memoized { DeprecatedBlockTag() } - describe("DeprecatedBlockTag rule") { - it("does not report regular kdoc block") { +class DeprecatedBlockTagSpec { + val subject = DeprecatedBlockTag() + + @Nested + inner class `DeprecatedBlockTag rule` { + @Test + fun `does not report regular kdoc block`() { val code = """ /** * This is just a regular kdoc block. @@ -20,7 +23,8 @@ class DeprecatedBlockTagSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(0) } - describe("reporting deprecation tag on kdoc block") { + @Nested + inner class `reporting deprecation tag on kdoc block` { val code = """ /** * I am a KDoc block @@ -30,11 +34,13 @@ class DeprecatedBlockTagSpec : Spek({ fun ohNo() { } """ - it("has found something") { + @Test + fun `has found something`() { assertThat(subject.compileAndLint(code)).hasSize(1) } - it("correct message") { + @Test + fun `correct message`() { assertThat(subject.compileAndLint(code)[0]).hasMessage( "@deprecated tag block does not properly report " + "deprecation in Kotlin, use @Deprecated annotation instead" @@ -42,9 +48,11 @@ class DeprecatedBlockTagSpec : Spek({ } } - describe("reporting deprecation tag wherever @Deprecated is available") { + @Nested + inner class `reporting deprecation tag wherever @Deprecated is available` { - it("report deprecation tag on class") { + @Test + fun `report deprecation tag on class`() { val code = """ /** * Hello there @@ -56,7 +64,8 @@ class DeprecatedBlockTagSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("report deprecation tag on property") { + @Test + fun `report deprecation tag on property`() { val code = """ class Thing { /** @@ -70,7 +79,8 @@ class DeprecatedBlockTagSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("report deprecation tag on annotation class") { + @Test + fun `report deprecation tag on annotation class`() { val code = """ /** * An annotation you should not use @@ -82,7 +92,8 @@ class DeprecatedBlockTagSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("report deprecation tag on constructor") { + @Test + fun `report deprecation tag on constructor`() { val code = """ class Thing { /** @@ -96,7 +107,8 @@ class DeprecatedBlockTagSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("report deprecation tag on property setter") { + @Test + fun `report deprecation tag on property setter`() { val code = """ class Thing { var someProperty: Int @@ -112,7 +124,8 @@ class DeprecatedBlockTagSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("report deprecation tag on property getter") { + @Test + fun `report deprecation tag on property getter`() { val code = """ class Thing { var someProperty: Int @@ -128,7 +141,8 @@ class DeprecatedBlockTagSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("report deprecation tag on typealias") { + @Test + fun `report deprecation tag on typealias`() { val code = """ /** * This alias is pointless, do not use it @@ -141,4 +155,4 @@ class DeprecatedBlockTagSpec : Spek({ } } } -}) +} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt index 80f8bb12909..228e5e49f68 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt @@ -2,15 +2,17 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.compileAndLint import org.assertj.core.api.Assertions.assertThat -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test -class EndOfSentenceFormatSpec : Spek({ - val subject by memoized { EndOfSentenceFormat() } +class EndOfSentenceFormatSpec { + val subject = EndOfSentenceFormat() - describe("KDocStyle rule") { + @Nested + inner class `KDocStyle rule` { - it("reports invalid KDoc endings on classes") { + @Test + fun `reports invalid KDoc endings on classes`() { val code = """ /** Some doc */ class Test { @@ -19,7 +21,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports invalid KDoc endings on function with expression body") { + @Test + fun `reports invalid KDoc endings on function with expression body`() { val code = """ /** Some doc */ fun f(x: Int, y: Int, z: Int) = @@ -28,7 +31,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports invalid KDoc endings on properties") { + @Test + fun `reports invalid KDoc endings on properties`() { val code = """ class Test { /** Some doc */ @@ -38,7 +42,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports invalid KDoc endings on top-level functions") { + @Test + fun `reports invalid KDoc endings on top-level functions`() { val code = """ /** Some doc */ fun test() = 3 @@ -46,7 +51,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports invalid KDoc endings on functions") { + @Test + fun `reports invalid KDoc endings on functions`() { val code = """ class Test { /** Some doc */ @@ -56,7 +62,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports invalid KDoc endings") { + @Test + fun `reports invalid KDoc endings`() { val code = """ class Test { /** Some doc-- */ @@ -66,7 +73,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports invalid KDoc endings in block") { + @Test + fun `reports invalid KDoc endings in block`() { val code = """ /** * Something off abc@@ @@ -77,7 +85,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("does not validate first sentence KDoc endings in a multi sentence comment") { + @Test + fun `does not validate first sentence KDoc endings in a multi sentence comment`() { val code = """ /** * This sentence is correct. @@ -90,7 +99,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report KDoc which doesn't contain any real sentence") { + @Test + fun `does not report KDoc which doesn't contain any real sentence`() { val code = """ /** */ @@ -100,7 +110,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report KDoc which doesn't contain any real sentence but many tags") { + @Test + fun `does not report KDoc which doesn't contain any real sentence but many tags`() { val code = """ /** * @configuration this - just an example (default: `150`) @@ -113,7 +124,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report KDoc which doesn't contain any real sentence but html tags") { + @Test + fun `does not report KDoc which doesn't contain any real sentence but html tags`() { val code = """ /** * @@ -132,7 +144,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report KDoc ending with periods") { + @Test + fun `does not report KDoc ending with periods`() { val code = """ /** * Something correct. @@ -143,7 +156,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report KDoc ending with questionmarks") { + @Test + fun `does not report KDoc ending with questionmarks`() { val code = """ /** * Something correct? @@ -154,7 +168,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report KDoc ending with exclamation marks") { + @Test + fun `does not report KDoc ending with exclamation marks`() { val code = """ /** * Something correct! @@ -165,7 +180,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report KDoc ending with colon") { + @Test + fun `does not report KDoc ending with colon`() { val code = """ /** * Something correct: @@ -176,7 +192,8 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report URLs in comments") { + @Test + fun `does not report URLs in comments`() { val code = """ /** http://www.google.com */ class Test1 { @@ -190,4 +207,4 @@ class EndOfSentenceFormatSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } } -}) +} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyleSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyleSpec.kt index 61eed65bbc0..9355b5ecc70 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyleSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyleSpec.kt @@ -2,15 +2,17 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.compileAndLint import org.assertj.core.api.Assertions.assertThat -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test -class KDocStyleSpec : Spek({ - val subject by memoized { KDocStyle() } +class KDocStyleSpec { + val subject = KDocStyle() - describe("check referenced multi rule to only lint errors once per case") { + @Nested + inner class `check referenced multi rule to only lint errors once per case` { - it("does only lint once") { + @Test + fun `does only lint once`() { val code = """ /** Some doc */ class Test { @@ -19,4 +21,4 @@ class KDocStyleSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } } -}) +} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt index da7d72e7228..51aea7de7c4 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt @@ -3,23 +3,27 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.TestConfig import io.gitlab.arturbosch.detekt.test.compileAndLint import org.assertj.core.api.Assertions.assertThat -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test -class OutdatedDocumentationSpec : Spek({ - val subject by memoized { OutdatedDocumentation() } +class OutdatedDocumentationSpec { + val subject = OutdatedDocumentation() - describe("OutdatedDocumentation rule") { + @Nested + inner class `OutdatedDocumentation rule` { - describe("general") { - it("should not report when doc is missing") { + @Nested + inner class `general` { + @Test + fun `should not report when doc is missing`() { val withoutDoc = """ class MyClass(someParam: String, val someProp: String) """ assertThat(subject.compileAndLint(withoutDoc)).isEmpty() } - it("should not report when doc does not contain any property or param tags") { + @Test + fun `should not report when doc does not contain any property or param tags`() { val docWithoutParamAndPropertyTags = """ /** * Some class description without referring to tags or properties @@ -30,8 +34,10 @@ class OutdatedDocumentationSpec : Spek({ } } - describe("class") { - it("should not report when doc match class params") { + @Nested + inner class `class` { + @Test + fun `should not report when doc match class params`() { val correctParam = """ /** * @param someParam Description of param @@ -41,7 +47,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(correctParam)).isEmpty() } - it("should report when doc mismatch class param name") { + @Test + fun `should report when doc mismatch class param name`() { val incorrectParamName = """ /** * @param someParam Description of param @@ -51,7 +58,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(incorrectParamName)).hasSize(1) } - it("should report when doc mismatch class param list") { + @Test + fun `should report when doc mismatch class param list`() { val incorrectListOfParams = """ /** * @param someParam Description of param @@ -62,7 +70,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(incorrectListOfParams)).hasSize(1) } - it("should report when doc mismatch class param list order") { + @Test + fun `should report when doc mismatch class param list order`() { val incorrectParamOrder = """ /** * @param someParam Description of param @@ -73,7 +82,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(incorrectParamOrder)).hasSize(1) } - it("should not report when doc match class params and props") { + @Test + fun `should not report when doc match class params and props`() { val correctParamAndProp = """ /** * @param someParam Description of param @@ -84,7 +94,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(correctParamAndProp)).isEmpty() } - it("should report when doc match class params but mismatch props") { + @Test + fun `should report when doc match class params but mismatch props`() { val correctParamIncorrectProp = """ /** * @param someParam Description of param @@ -95,7 +106,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(correctParamIncorrectProp)).hasSize(1) } - it("should report when doc mismatch class params and match props") { + @Test + fun `should report when doc mismatch class params and match props`() { val incorrectParamCorrectProp = """ /** * @param someParam Description of param @@ -106,7 +118,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(incorrectParamCorrectProp)).hasSize(1) } - it("should report when doc for constructor is incorrect") { + @Test + fun `should report when doc for constructor is incorrect`() { val incorrectConstructorDoc = """ class MyClass { /** @@ -118,7 +131,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(incorrectConstructorDoc)).hasSize(1) } - it("should report when property is documented as param") { + @Test + fun `should report when property is documented as param`() { val propertyAsParam = """ /** * @property someParam Description of param @@ -129,7 +143,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(propertyAsParam)).hasSize(1) } - it("should report when declarations order is incorrect") { + @Test + fun `should report when declarations order is incorrect`() { val incorrectDeclarationsOrder = """ /** * @property someProp Description of property @@ -141,9 +156,11 @@ class OutdatedDocumentationSpec : Spek({ } } - describe("class with type params") { + @Nested + inner class `class with type params` { - it("should not report when doc match class params") { + @Test + fun `should not report when doc match class params`() { val correctTypeParam = """ /** * @param T Description of type param @@ -154,7 +171,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(correctTypeParam)).isEmpty() } - it("should report when doc misses type param") { + @Test + fun `should report when doc misses type param`() { val missingTypeParam = """ /** * @param someParam Description of param @@ -164,7 +182,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(missingTypeParam)).hasSize(1) } - it("should report when doc mismatch type param name") { + @Test + fun `should report when doc mismatch type param name`() { val incorrectTypeParamName = """ /** * @param S Description of type param @@ -175,7 +194,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(incorrectTypeParamName)).hasSize(1) } - it("should report when doc mismatch type param list") { + @Test + fun `should report when doc mismatch type param list`() { val incorrectTypeParamList = """ /** * @param T Description of type param @@ -187,9 +207,11 @@ class OutdatedDocumentationSpec : Spek({ } } - describe("function") { + @Nested + inner class `function` { - it("should not report when doc match function params") { + @Test + fun `should not report when doc match function params`() { val correctDoc = """ /** * @param someParam Description of param @@ -199,7 +221,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(correctDoc)).isEmpty() } - it("should report when doc mismatch function param name") { + @Test + fun `should report when doc mismatch function param name`() { val incorrectParamName = """ /** * @param someParam Description of param @@ -210,9 +233,11 @@ class OutdatedDocumentationSpec : Spek({ } } - describe("function with type params") { + @Nested + inner class `function with type params` { - it("should not report when doc match function params") { + @Test + fun `should not report when doc match function params`() { val correctTypeParam = """ /** * @param T Description of type param @@ -223,7 +248,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(correctTypeParam)).isEmpty() } - it("should report when doc misses type param") { + @Test + fun `should report when doc misses type param`() { val missingTypeParam = """ /** * @param someParam Description of param @@ -233,7 +259,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(missingTypeParam)).hasSize(1) } - it("should report when doc mismatch type param name") { + @Test + fun `should report when doc mismatch type param name`() { val incorrectTypeParamName = """ /** * @param S Description of type param @@ -244,7 +271,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(incorrectTypeParamName)).hasSize(1) } - it("should report when doc mismatch type param list") { + @Test + fun `should report when doc mismatch type param list`() { val incorrectTypeParamList = """ /** * @param T Description of type param @@ -255,7 +283,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(incorrectTypeParamList)).hasSize(1) } - it("should report when not all type params are first declarations of doc") { + @Test + fun `should report when not all type params are first declarations of doc`() { val incorrectTypeParamsOrder = """ /** * @param T Description of type param @@ -268,9 +297,11 @@ class OutdatedDocumentationSpec : Spek({ } } - describe("advanced scenarios") { + @Nested + inner class `advanced scenarios` { - it("should not report when doc match all signatures") { + @Test + fun `should not report when doc match all signatures`() { val correctClassWithFunction = """ /** * @param someParam Description of param @@ -285,7 +316,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(subject.compileAndLint(correctClassWithFunction)).isEmpty() } - it("should report for every class and function with incorrect doc") { + @Test + fun `should report for every class and function with incorrect doc`() { val incorrectClassWithTwoIncorrectFunctions = """ /** * @param someParam Description of param @@ -309,12 +341,13 @@ class OutdatedDocumentationSpec : Spek({ } } - describe("configuration matchTypeParameters") { - val configuredSubject by memoized { + @Nested + inner class `configuration matchTypeParameters` { + val configuredSubject = OutdatedDocumentation(TestConfig(mapOf("matchTypeParameters" to "false"))) - } - it("should not report when class type parameters mismatch and configuration is off") { + @Test + fun `should not report when class type parameters mismatch and configuration is off`() { val incorrectClassTypeParams = """ /** * @param someParam Description of param @@ -324,7 +357,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(configuredSubject.compileAndLint(incorrectClassTypeParams)).isEmpty() } - it("should not report when function type parameters mismatch and configuration is off") { + @Test + fun `should not report when function type parameters mismatch and configuration is off`() { val incorrectFunctionTypeParams = """ /** * @param someParam Description of param @@ -335,12 +369,13 @@ class OutdatedDocumentationSpec : Spek({ } } - describe("configuration matchDeclarationsOrder") { - val configuredSubject by memoized { + @Nested + inner class `configuration matchDeclarationsOrder` { + val configuredSubject = OutdatedDocumentation(TestConfig(mapOf("matchDeclarationsOrder" to "false"))) - } - it("should not report when declarations order mismatch and configuration is off") { + @Test + fun `should not report when declarations order mismatch and configuration is off`() { val incorrectDeclarationsOrder = """ /** * @param someParam Description of param @@ -351,7 +386,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(configuredSubject.compileAndLint(incorrectDeclarationsOrder)).isEmpty() } - it("should not report when declarations with types order mismatch and configuration is off") { + @Test + fun `should not report when declarations with types order mismatch and configuration is off`() { val incorrectDeclarationsOrderWithType = """ /** * @param S Description of type param @@ -364,12 +400,14 @@ class OutdatedDocumentationSpec : Spek({ assertThat(configuredSubject.compileAndLint(incorrectDeclarationsOrderWithType)).isEmpty() } } - describe("configuration allowParamOnConstructorProperties") { - val configuredSubject by memoized { + + @Nested + inner class `configuration allowParamOnConstructorProperties` { + val configuredSubject = OutdatedDocumentation(TestConfig(mapOf("allowParamOnConstructorProperties" to "true"))) - } - it("should not report when property is documented as param") { + @Test + fun `should not report when property is documented as param`() { val propertyAsParam = """ /** * @param someParam Description of param @@ -380,7 +418,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(configuredSubject.compileAndLint(propertyAsParam)).isEmpty() } - it("should not report when property is documented as property") { + @Test + fun `should not report when property is documented as property`() { val propertyAsParam = """ /** * @param someParam Description of param @@ -392,8 +431,9 @@ class OutdatedDocumentationSpec : Spek({ } } - describe("configuration matchDeclarationsOrder and allowParamOnConstructorProperties") { - val configuredSubject by memoized { + @Nested + inner class `configuration matchDeclarationsOrder and allowParamOnConstructorProperties` { + val configuredSubject = OutdatedDocumentation( TestConfig( mapOf( @@ -402,9 +442,9 @@ class OutdatedDocumentationSpec : Spek({ ) ) ) - } - it("should not report when property is documented as param") { + @Test + fun `should not report when property is documented as param`() { val propertyAsParam = """ /** * @param someParam Description of param @@ -415,7 +455,8 @@ class OutdatedDocumentationSpec : Spek({ assertThat(configuredSubject.compileAndLint(propertyAsParam)).isEmpty() } - it("should not report when property is documented as property") { + @Test + fun `should not report when property is documented as property`() { val propertyAsParam = """ /** * @param someParam Description of param @@ -427,4 +468,4 @@ class OutdatedDocumentationSpec : Spek({ } } } -}) +} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicClassSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicClassSpec.kt index 070f11ef2fd..226ed3c831c 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicClassSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicClassSpec.kt @@ -3,16 +3,16 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.TestConfig import io.gitlab.arturbosch.detekt.test.compileAndLint import org.assertj.core.api.Assertions.assertThat -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test private const val SEARCH_IN_NESTED_CLASS = "searchInNestedClass" private const val SEARCH_IN_INNER_CLASS = "searchInInnerClass" private const val SEARCH_IN_INNER_OBJECT = "searchInInnerObject" private const val SEARCH_IN_INNER_INTERFACE = "searchInInnerInterface" -class UndocumentedPublicClassSpec : Spek({ - val subject by memoized { UndocumentedPublicClass() } +class UndocumentedPublicClassSpec { + val subject = UndocumentedPublicClass() val inner = """ /** Some doc */ @@ -55,53 +55,65 @@ class UndocumentedPublicClassSpec : Spek({ val privateClass = "private class TestNested {}" val internalClass = "internal class TestNested {}" - describe("UndocumentedPublicClass rule") { + @Nested + inner class `UndocumentedPublicClass rule` { - it("should report inner classes by default") { + @Test + fun `should report inner classes by default`() { assertThat(subject.compileAndLint(inner)).hasSize(1) } - it("should report inner object by default") { + @Test + fun `should report inner object by default`() { assertThat(subject.compileAndLint(innerObject)).hasSize(1) } - it("should report inner interfaces by default") { + @Test + fun `should report inner interfaces by default`() { assertThat(subject.compileAndLint(innerInterface)).hasSize(1) } - it("should report nested classes by default") { + @Test + fun `should report nested classes by default`() { assertThat(subject.compileAndLint(nested)).hasSize(1) } - it("should report explicit public nested classes by default") { + @Test + fun `should report explicit public nested classes by default`() { assertThat(subject.compileAndLint(nestedPublic)).hasSize(1) } - it("should not report internal classes") { + @Test + fun `should not report internal classes`() { assertThat(subject.compileAndLint(internalClass)).isEmpty() } - it("should not report private classes") { + @Test + fun `should not report private classes`() { assertThat(subject.compileAndLint(privateClass)).isEmpty() } - it("should not report nested private classes") { + @Test + fun `should not report nested private classes`() { assertThat(subject.compileAndLint(nestedPrivate)).isEmpty() } - it("should not report inner classes when turned off") { + @Test + fun `should not report inner classes when turned off`() { val findings = UndocumentedPublicClass(TestConfig(mapOf(SEARCH_IN_INNER_CLASS to "false"))).compileAndLint(inner) assertThat(findings).isEmpty() } - it("should not report inner objects when turned off") { + @Test + fun `should not report inner objects when turned off`() { val findings = UndocumentedPublicClass(TestConfig(mapOf(SEARCH_IN_INNER_OBJECT to "false"))).compileAndLint(innerObject) assertThat(findings).isEmpty() } - it("should not report inner interfaces when turned off") { + @Test + fun `should not report inner interfaces when turned off`() { val findings = UndocumentedPublicClass(TestConfig(mapOf(SEARCH_IN_INNER_INTERFACE to "false"))).compileAndLint( innerInterface @@ -109,17 +121,20 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(findings).isEmpty() } - it("should not report nested classes when turned off") { + @Test + fun `should not report nested classes when turned off`() { val findings = UndocumentedPublicClass(TestConfig(mapOf(SEARCH_IN_NESTED_CLASS to "false"))).compileAndLint(nested) assertThat(findings).isEmpty() } - it("should report missing doc over object declaration") { + @Test + fun `should report missing doc over object declaration`() { assertThat(subject.compileAndLint("object o")).hasSize(1) } - it("should not report non-public nested classes") { + @Test + fun `should not report non-public nested classes`() { val code = """ internal class Outer { class Nested @@ -129,7 +144,8 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("should not report non-public nested interfaces") { + @Test + fun `should not report non-public nested interfaces`() { val code = """ internal class Outer { interface Inner @@ -138,7 +154,8 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("should not report non-public nested objects") { + @Test + fun `should not report non-public nested objects`() { val code = """ internal class Outer { object Inner @@ -147,7 +164,8 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("should not report for documented public object") { + @Test + fun `should not report for documented public object`() { val code = """ /** * Class docs not being recognized. @@ -166,7 +184,8 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("should not report for anonymous objects") { + @Test + fun `should not report for anonymous objects`() { val code = """ fun main(args: Array) { val value = object : Iterator { @@ -178,7 +197,8 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("should report for enum classes") { + @Test + fun `should report for enum classes`() { val code = """ enum class Enum { CONSTANT @@ -187,7 +207,8 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("should not report for enum constants") { + @Test + fun `should not report for enum constants`() { val code = """ /** Some doc */ enum class Enum { @@ -197,7 +218,8 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("should not report for fun interfaces") { + @Test + fun `should not report for fun interfaces`() { val code = """ /** * This interface is an example @@ -212,4 +234,4 @@ class UndocumentedPublicClassSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } } -}) +} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunctionSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunctionSpec.kt index 9afdc0261d5..f83a529b84c 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunctionSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunctionSpec.kt @@ -2,22 +2,25 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.compileAndLint import org.assertj.core.api.Assertions.assertThat -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test -class UndocumentedPublicFunctionSpec : Spek({ - val subject by memoized { UndocumentedPublicFunction() } +class UndocumentedPublicFunctionSpec { + val subject = UndocumentedPublicFunction() - describe("UndocumentedPublicFunction rule") { + @Nested + inner class `UndocumentedPublicFunction rule` { - it("reports undocumented public functions") { + @Test + fun `reports undocumented public functions`() { val code = """ fun noComment1() {} """ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public function in object") { + @Test + fun `reports undocumented public function in object`() { val code = """ object Test { fun noComment1() {} @@ -26,7 +29,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public function in nested object") { + @Test + fun `reports undocumented public function in nested object`() { val code = """ class Test { object Test2 { @@ -37,7 +41,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public functions in companion object") { + @Test + fun `reports undocumented public functions in companion object`() { val code = """ class Test { companion object { @@ -49,7 +54,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(2) } - it("reports undocumented public function in an interface") { + @Test + fun `reports undocumented public function in an interface`() { val code = """ interface Test { fun noComment1() @@ -58,7 +64,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("does not report documented public function") { + @Test + fun `does not report documented public function`() { val code = """ /** * Comment @@ -68,7 +75,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report documented public function in class") { + @Test + fun `does not report documented public function in class`() { val code = """ class Test { /** @@ -80,7 +88,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented internal and private function") { + @Test + fun `does not report undocumented internal and private function`() { val code = """ class Test { internal fun no1(){} @@ -90,7 +99,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented nested function") { + @Test + fun `does not report undocumented nested function`() { val code = """ /** * Comment @@ -102,7 +112,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report public functions in internal class") { + @Test + fun `does not report public functions in internal class`() { val code = """ internal class NoComments { fun nope1() {} @@ -112,7 +123,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report public functions in private class") { + @Test + fun `does not report public functions in private class`() { val code = """ private class NoComments { fun nope1() {} @@ -122,7 +134,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report public functions in private object") { + @Test + fun `does not report public functions in private object`() { val code = """ private object Test { fun noComment1() {} @@ -131,8 +144,10 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - context("nested class") { - it("does not report public functions in internal interface") { + @Nested + inner class `nested class` { + @Test + fun `does not report public functions in internal interface`() { val code = """ internal interface Foo { interface Bar { @@ -144,7 +159,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report public functions in private class") { + @Test + fun `does not report public functions in private class`() { val code = """ class Foo { private class Bar { @@ -158,7 +174,8 @@ class UndocumentedPublicFunctionSpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report public functions in private object") { + @Test + fun `does not report public functions in private object`() { val code = """ private object Foo { class Bar { @@ -171,4 +188,4 @@ class UndocumentedPublicFunctionSpec : Spek({ } } } -}) +} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicPropertySpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicPropertySpec.kt index eb310ee0444..b91d75abd5a 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicPropertySpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicPropertySpec.kt @@ -2,20 +2,23 @@ package io.gitlab.arturbosch.detekt.rules.documentation import io.gitlab.arturbosch.detekt.test.compileAndLint import org.assertj.core.api.Assertions.assertThat -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test -class UndocumentedPublicPropertySpec : Spek({ - val subject by memoized { UndocumentedPublicProperty() } +class UndocumentedPublicPropertySpec { + val subject = UndocumentedPublicProperty() - describe("UndocumentedPublicProperty rule") { + @Nested + inner class `UndocumentedPublicProperty rule` { - it("reports undocumented public property") { + @Test + fun `reports undocumented public property`() { val code = "val a = 1" assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public property in objects") { + @Test + fun `reports undocumented public property in objects`() { val code = """ object Test { val a = 1 @@ -24,7 +27,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public property in nested objects") { + @Test + fun `reports undocumented public property in nested objects`() { val code = """ class Test { object NestedTest { @@ -35,7 +39,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public properties in companion object") { + @Test + fun `reports undocumented public properties in companion object`() { val code = """ class Test { companion object { @@ -47,7 +52,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(2) } - it("reports undocumented public property in an interface") { + @Test + fun `reports undocumented public property in an interface`() { val code = """ interface Test { val a: Int @@ -56,17 +62,20 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public properties in a primary constructor") { + @Test + fun `reports undocumented public properties in a primary constructor`() { val code = "class Test(val a: Int)" assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public property in a primary constructor") { + @Test + fun `reports undocumented public property in a primary constructor`() { val code = "/* comment */ class Test(val a: Int)" assertThat(subject.compileAndLint(code)).hasSize(1) } - it("does not report documented public property") { + @Test + fun `does not report documented public property`() { val code = """ /** * Comment @@ -76,7 +85,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report documented public property in class") { + @Test + fun `does not report documented public property in class`() { val code = """ class Test { /** @@ -88,7 +98,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented, public and overridden property in class") { + @Test + fun `does not report undocumented, public and overridden property in class`() { val code = """ interface I { /** @@ -104,7 +115,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented internal and private property") { + @Test + fun `does not report undocumented internal and private property`() { val code = """ class Test { internal val a = 1 @@ -114,7 +126,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report local variables") { + @Test + fun `does not report local variables`() { val code = """ fun commented(x: Int) { var a = x @@ -123,7 +136,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report public properties in internal class") { + @Test + fun `does not report public properties in internal class`() { val code = """ internal class NoComments { public val a = 1 @@ -133,7 +147,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report public properties in private class") { + @Test + fun `does not report public properties in private class`() { val code = """ private class NoComments { public val a = 1 @@ -143,7 +158,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report properties in a secondary constructor") { + @Test + fun `does not report properties in a secondary constructor`() { val code = """ class Test() { constructor(a: Int) : this() @@ -152,7 +168,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented non-public properties in a primary constructor") { + @Test + fun `does not report undocumented non-public properties in a primary constructor`() { val code = """ class Test1(internal val a: Int) class Test2(b: Int) @@ -160,12 +177,14 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented public properties in a primary constructor for an internal class") { + @Test + fun `does not report undocumented public properties in a primary constructor for an internal class`() { val code = "internal class Test(val a: Int)" assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report documented public properties in a primary constructor") { + @Test + fun `does not report documented public properties in a primary constructor`() { val code = """ /** * @property a int1 @@ -187,7 +206,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented public properties in private object") { + @Test + fun `does not report undocumented public properties in private object`() { val code = """ private object Test { val a = 1 @@ -196,9 +216,11 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - describe("public properties in nested classes") { + @Nested + inner class `public properties in nested classes` { - it("reports undocumented public properties in nested classes") { + @Test + fun `reports undocumented public properties in nested classes`() { val code = """ class Outer { class Inner { @@ -213,7 +235,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(2) } - it("reports undocumented public properties in inner classes") { + @Test + fun `reports undocumented public properties in inner classes`() { val code = """ class Outer { inner class Inner { @@ -224,7 +247,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("reports undocumented public properties in classes nested in objects") { + @Test + fun `reports undocumented public properties in classes nested in objects`() { val code = """ object Outer { class Inner { @@ -235,7 +259,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("does not report undocumented and non-public properties in nested classes") { + @Test + fun `does not report undocumented and non-public properties in nested classes`() { val code = """ internal class Outer { class Inner { @@ -246,7 +271,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented and non-public properties in inner classes") { + @Test + fun `does not report undocumented and non-public properties in inner classes`() { val code = """ internal class Outer { inner class Inner { @@ -258,9 +284,11 @@ class UndocumentedPublicPropertySpec : Spek({ } } - describe("public properties in primary constructors inside nested classes") { + @Nested + inner class `public properties in primary constructors inside nested classes` { - it("reports undocumented public properties in nested classes") { + @Test + fun `reports undocumented public properties in nested classes`() { val code = """ class Outer(val a: Int) { class Inner(val b: Int) { @@ -271,7 +299,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(3) } - it("reports undocumented public properties in inner classes") { + @Test + fun `reports undocumented public properties in inner classes`() { val code = """ class Outer(val a: Int) { inner class Inner(val b: Int) @@ -280,7 +309,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(2) } - it("reports undocumented public properties in classes nested in objects") { + @Test + fun `reports undocumented public properties in classes nested in objects`() { val code = """ object Outer { class Inner(val a: Int) @@ -289,7 +319,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).hasSize(1) } - it("does not report undocumented and non-public properties in nested classes") { + @Test + fun `does not report undocumented and non-public properties in nested classes`() { val code = """ internal class Outer(val a: Int) { class Inner(val b: Int) @@ -298,7 +329,8 @@ class UndocumentedPublicPropertySpec : Spek({ assertThat(subject.compileAndLint(code)).isEmpty() } - it("does not report undocumented and non-public properties in inner classes") { + @Test + fun `does not report undocumented and non-public properties in inner classes`() { val code = """ internal class Outer(val a: Int) { inner class Inner(val b: Int) @@ -308,4 +340,4 @@ class UndocumentedPublicPropertySpec : Spek({ } } } -}) +}