From c3fc19ffe8077af13786f84cd6f013d2fae78604 Mon Sep 17 00:00:00 2001 From: Adam Semenenko <152864218+adam-enko@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:54:40 +0100 Subject: [PATCH] add assertion for 'unknown class' errors --- .../kotlin/ExampleProjectsTest.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/dokka-integration-tests/gradle/src/testExampleProjects/kotlin/ExampleProjectsTest.kt b/dokka-integration-tests/gradle/src/testExampleProjects/kotlin/ExampleProjectsTest.kt index 5eef208a91..6ac6857bd8 100644 --- a/dokka-integration-tests/gradle/src/testExampleProjects/kotlin/ExampleProjectsTest.kt +++ b/dokka-integration-tests/gradle/src/testExampleProjects/kotlin/ExampleProjectsTest.kt @@ -5,9 +5,12 @@ package org.jetbrains.dokka.it.gradle.examples import io.kotest.assertions.asClue import io.kotest.assertions.withClue +import io.kotest.inspectors.shouldForAll import io.kotest.matchers.paths.shouldBeADirectory +import io.kotest.matchers.sequences.shouldNotBeEmpty import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldContain +import io.kotest.matchers.string.shouldNotContain import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.TaskOutcome.FROM_CACHE import org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE @@ -165,6 +168,11 @@ class ExampleProjectsTest { testCase = testCase, format = "html", ) + + verifyNoUnknownClassErrorsInHtmlFiles( + testCase = testCase, + format = "html", + ) } @ParameterizedTest @@ -216,6 +224,29 @@ class ExampleProjectsTest { } } + private fun verifyNoUnknownClassErrorsInHtmlFiles( + testCase: TestCase, + format: String, + ) { + val dokkaOutputDir = testCase.dokkaOutputDir.resolve(format) + + withClue("expect no 'unknown class' message in output files") { + val htmlFiles = dokkaOutputDir.walk() + .filter { it.isRegularFile() && it.extension == "html" } + + htmlFiles.shouldNotBeEmpty() + + htmlFiles.forEach { file -> + val relativePath = file.relativeTo(dokkaOutputDir) + withClue("$relativePath should not contain Error class: unknown class") { + file.useLines { lines -> + lines.shouldForAll { line -> line.shouldNotContain("Error class: unknown class") } + } + } + } + } + } + @ParameterizedTest @ArgumentsSource(TestCaseProvider::class)