Skip to content

Commit

Permalink
Add kotest-assertions to common test dependencies (#445)
Browse files Browse the repository at this point in the history
* Add kotest assertions to common test dependencies
* Start using them in some tests
* Remove duplicated conversion to sequence

Part of #408
  • Loading branch information
petertrr authored Dec 1, 2022
1 parent 101ce22 commit e557722
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ kotlin {
languageSettings.optIn("kotlin.RequiresOptIn")
}
val commonMain by getting
val commonTest by getting
val commonTest by getting {
dependencies {
implementation("io.kotest:kotest-assertions-core:5.3.0")
}
}
val commonNonJsMain by creating {
dependsOn(commonMain)
}
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ junit = "5.9.1"
ktoml = "0.3.0"
multiplatform-diff = "0.4.0"
kotlinpoet = "1.12.0"
kotest = "5.3.0"
sarif4k = "0.3.0"

[plugins]
Expand All @@ -34,4 +35,5 @@ ktoml-file = { module = "com.akuleshov7:ktoml-file", version.ref = "ktoml" }
multiplatform-diff = { module = "io.github.petertrr:kotlin-multiplatform-diff", version.ref = "multiplatform-diff" }
square-kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" }
diktat-gradle-plugin = { module = "org.cqfn.diktat:diktat-gradle-plugin", version.ref = "diktat" }
sarif4k = { module = "io.github.detekt.sarif4k:sarif4k", version.ref = "sarif4k" }
sarif4k = { module = "io.github.detekt.sarif4k:sarif4k", version.ref = "sarif4k" }
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ internal fun List<String>.filterAndJoinBy(regex: Regex, ending: Char): List<Stri

/**
* Split [this] string by [delimiter] unless it's prepended by `\`.
* fixme: allow escaping of slashes, i.e. `\\,` shouldn't lead to splitting.
*
* @param delimiter
* @return list of string parts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.saveourtool.save.core.integration

import com.saveourtool.save.core.test.utils.runTestsWithDiktat
import io.kotest.matchers.collections.exist
import io.kotest.matchers.shouldNot

import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertTrue

@Ignore // https://github.com/saveourtool/save-cli/issues/402
class WarnDirTest {
Expand All @@ -31,8 +32,8 @@ class WarnDirTest {
@Test
fun `execute warn plugin on root directory`() {
val reporter = runTestsWithDiktat(listOf("warn-dir"), 6)
reporter.results.forEach { testResult ->
assertTrue(!testResult.debugInfo!!.execCmd!!.contains("chapter"))
reporter.results shouldNot exist { testResult ->
testResult.debugInfo!!.execCmd!!.contains("chapter")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.saveourtool.save.core.result.Fail
import com.saveourtool.save.core.result.Ignored
import com.saveourtool.save.core.result.Pass
import com.saveourtool.save.reporter.test.TestReporter
import io.kotest.matchers.types.shouldBeTypeOf

import okio.Path

Expand Down Expand Up @@ -79,7 +80,7 @@ fun runTestsWithDiktat(
if (test.status is Ignored) {
assertEquals(Ignored("Excluded by configuration"), test.status)
} else {
assertTrue(test.status is Pass)
test.status.shouldBeTypeOf<Pass>()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class WarnPlugin(
//
// In case, when user doesn't want to use directory mode, he needs simply not to pass [wildCardInDirectoryMode] and it will be null
return warnPluginConfig.wildCardInDirectoryMode?.let {
handleTestFile(files.map { it.test }.toList(), warnPluginConfig, generalConfig, batchSeparator).asSequence()
handleTestFile(files.map { it.test }.toList(), warnPluginConfig, generalConfig, batchSeparator)
} ?: run {
files.chunked(batchSize).flatMap { chunk ->
handleTestFile(chunk.map { it.test }, warnPluginConfig, generalConfig, batchSeparator)
Expand Down

0 comments on commit e557722

Please sign in to comment.