diff --git a/settings.gradle.kts b/settings.gradle.kts index 02a0484..ad74d1d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -64,6 +64,7 @@ include( "dokka-mkdocs", "test-data", + "test-runner", "gradle:templates:template-app", "gradle:templates:template-lib", diff --git a/test-data/src/commonMain/kotlin/helloworld/HelloWorld.kt b/test-data/src/commonMain/kotlin/helloworld/HelloWorld.kt new file mode 100644 index 0000000..b2f1a92 --- /dev/null +++ b/test-data/src/commonMain/kotlin/helloworld/HelloWorld.kt @@ -0,0 +1,6 @@ +package opensavvy.dokka.material.mkdocs.test.helloworld + +/** + * This is the simplest possible Kotlin file: just a top-level constant with its documentation. + */ +const val HelloWorld = "Hello, world!" diff --git a/test-runner/README.md b/test-runner/README.md new file mode 100644 index 0000000..6bad79b --- /dev/null +++ b/test-runner/README.md @@ -0,0 +1,6 @@ +# Integration tests + +This module works alongside the [test-data](../test-data) module. + +- `test-data` contains real declarations. +- `test-runner` contains test code. diff --git a/test-runner/build.gradle.kts b/test-runner/build.gradle.kts new file mode 100644 index 0000000..87907e2 --- /dev/null +++ b/test-runner/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + alias(opensavvyConventions.plugins.base) + alias(opensavvyConventions.plugins.kotlin.internal) + alias(libsCommon.plugins.testBalloon) +} + +kotlin { + jvm() + + sourceSets.jvmTest.dependencies { + implementation(libsCommon.bundles.testBalloon) + implementation(libsCommon.opensavvy.prepared.filesystem) + implementation(libsCommon.opensavvy.prepared.gradle) + } +} diff --git a/test-runner/src/jvmTest/kotlin/FindTestCases.kt b/test-runner/src/jvmTest/kotlin/FindTestCases.kt new file mode 100644 index 0000000..8df1b7a --- /dev/null +++ b/test-runner/src/jvmTest/kotlin/FindTestCases.kt @@ -0,0 +1,26 @@ +package opensavvy.dokka.material.mkdocs.test + +import java.io.File + +fun findTestCases(): List { + val srcFolder = File("../test-data/src").absoluteFile + check(srcFolder.exists()) + check(srcFolder.isDirectory) + + val platformFolders = srcFolder.listFiles() + checkNotNull(platformFolders) { "No platform folders found in test data source" } + + val commonMain = platformFolders.firstOrNull { it.name == "commonMain" } + checkNotNull(commonMain) { "No commonMain folder found in test data source: ${srcFolder}/commonMain" } + + val testCases = platformFolders + .map { File(it, "kotlin") } + .flatMap { + it.listFiles()?.asList().orEmpty() + } + .filter { it.isDirectory } + .distinctBy { it.name } + check(testCases.isNotEmpty()) { "No test cases were found" } + + return testCases +} diff --git a/test-runner/src/jvmTest/kotlin/Runner.kt b/test-runner/src/jvmTest/kotlin/Runner.kt new file mode 100644 index 0000000..12b4732 --- /dev/null +++ b/test-runner/src/jvmTest/kotlin/Runner.kt @@ -0,0 +1,18 @@ +package opensavvy.dokka.material.mkdocs.test + +import opensavvy.prepared.runner.testballoon.preparedSuite + +val IntegrationTests by preparedSuite { + + val cases = findTestCases() + + test("At least one test was found") { + check(cases.isNotEmpty()) { "No integration tests were found, maybe something went wrong?" } + } + + for (case in cases) { + test("Test case: ${case.name}") { + check(case.isDirectory) + } + } +}