Best Kotest code snippet using io.kotest.matchers.paths.paths
GradlecumberPluginTest.kt
Source:GradlecumberPluginTest.kt
1package io.github.hWorblehat.gradlecumber2import io.github.hWorblehat.gradlecumber.analysis.ResultChecker3import io.github.hWorblehat.gradlecumber.dsl.CucumberExtension4import io.github.hWorblehat.gradlecumber.dsl.cucumberCheckResultsTaskName5import io.github.hWorblehat.gradlecumber.dsl.cucumberExecTaskName6import io.github.hWorblehat.gradlecumber.dsl.cucumberLifecycleTaskName7import io.github.hWorblehat.gradlecumber.testutil.BASE_PLUGIN_ID8import io.github.hWorblehat.gradlecumber.testutil.projectStruct9import io.github.hWorblehat.gradlecumber.testutil.tempdir10import io.github.hWorblehat.gradlecumber.testutil.testProject11import io.github.hWorblehat.gradlecumber.util.sourceSets12import io.kotest.assertions.throwables.shouldNotThrow13import io.kotest.core.spec.style.FreeSpec14import io.kotest.inspectors.forOne15import io.kotest.matchers.collections.beEmpty16import io.kotest.matchers.collections.shouldContain17import io.kotest.matchers.collections.shouldContainExactly18import io.kotest.matchers.collections.shouldContainInOrder19import io.kotest.matchers.collections.shouldNotContain20import io.kotest.matchers.maps.shouldContain21import io.kotest.matchers.should22import io.kotest.matchers.shouldBe23import io.kotest.matchers.shouldNotBe24import io.kotest.matchers.types.beInstanceOf25import org.gradle.language.base.plugins.LifecycleBasePlugin26import org.gradle.testkit.runner.GradleRunner27import org.gradle.testkit.runner.TaskOutcome.SKIPPED28@Suppress("UnstableApiUsage")29class GradlecumberPluginTest : FreeSpec({30 GradlecumberPlugin::class.simpleName!! - {31 "Applying the plugin creates associated model objects" - {32 val project = testProject()33 project.plugins.apply(GradlecumberPlugin::class.java)34 "the 'cucumber' extension" {35 val ext = project.extensions.getByName("cucumber")36 ext shouldNotBe null37 ext should beInstanceOf<CucumberExtension>()38 }39 "a 'cucumber' dependency configuration" {40 val conf = project.configurations.cucumber41 conf shouldNotBe null42 }43 }44 "Plugin can be applied by ID" {45 val project = testProject()46 project.plugins.apply(BASE_PLUGIN_ID)47 shouldNotThrow<Exception> {48 project.extensions.getByName("cucumber")49 }50 }51 "Adding a suite creates corresponding Gradle model objects" - {52 val project = testProject()53 project.plugins.apply(GradlecumberPlugin::class.java)54 project.cucumber.suites.register("testSuite")55 "a source set that" - {56 "exists" {57 shouldNotThrow<Exception> {58 project.sourceSets.getByName("testSuite")59 }60 }61 "has an 'implementation' configuration that extends the 'cucumber' configuration" {62 project.dependencies.apply {63 add(project.cucumber.configurationName, cucumberJava("6.+"))64 }65 val deps = project.configurations.getByName("testSuiteImplementation").allDependencies66 deps.forOne { dep ->67 dep.group shouldBe "io.cucumber"68 dep.name shouldBe "cucumber-java"69 }70 }71 }72 "a ${CucumberExec::class.simpleName} task with" - {73 val task = project.tasks.named(cucumberExecTaskName("testSuite"), CucumberExec::class.java).get()74 "a defined features directory" {75 task.features.args.get() shouldContainExactly listOf("${project.projectDir.absolutePath}/src/testSuite/gherkin")76 }77 "a message formatter" {78 val format = task.formats.named("message").get()79 format.pluginName.get() shouldBe "message"80 format.destFile.isPresent shouldBe true81 }82 }83 "a lifecycle task" {84 val lifecycle = project.tasks.named(cucumberLifecycleTaskName("testSuite")).get()85 lifecycle.actions should beEmpty()86 lifecycle.group shouldBe LifecycleBasePlugin.VERIFICATION_GROUP87 }88 }89 "Adding rules to a suite splits apart execution and analysis" - {90 val project = testProject()91 project.plugins.apply(GradlecumberPlugin::class.java)92 val gradleMajorVersion = project.gradle.gradleVersion.split(".")[0].toInt()93 val rules = ResultChecker { "Dummy" }94 project.cucumber.suites.register("testSuite") {95 it.rules(rules)96 }97 "the ${CucumberExec::class.simpleName} task will not fail if tests don't pass" {98 val task = project.tasks.named(cucumberExecTaskName("testSuite"), CucumberExec::class.java).get()99 task.allowNonPassingTests.get() shouldBe true100 }101 "a ${CucumberCheckResults::class.simpleName} task is added with" - {102 val task = project.tasks.named(cucumberCheckResultsTaskName("testSuite"), CucumberCheckResults::class.java).get()103 "a defined messages input file".config(104 enabled = gradleMajorVersion < 7105 ) {106 task.messages.isPresent shouldBe true107 }108 "the rules that were specified on the suite" {109 task.rules.get() shouldBe rules110 }111 }112 }113 "A test suite's configuration is passed on to its corresponding tasks" - {114 val project = testProject()115 project.plugins.apply(GradlecumberPlugin::class.java)116 "adding a formatter" {117 project.cucumber.suites.register("extraFormat") {118 it.format("dave") {119 pluginName.set("pretty")120 }121 }122 val task = project.tasks.named(cucumberExecTaskName("extraFormat"), CucumberExec::class.java).get()123 val format = task.formats.named("dave").get()124 format.pluginName.get() shouldBe "pretty"125 format.destURI.isPresent shouldBe false126 }127 "adding features" {128 project.cucumber.suites.register("extraFeatures") {129 it.features {130 rerun("rerun.txt")131 }132 }133 val task = project.tasks.named(cucumberExecTaskName("extraFeatures"), CucumberExec::class.java).get()134 task.features.allFiles shouldContain project.file("rerun.txt")135 task.features.args.get() shouldContain "@${project.file("rerun.txt").absolutePath}"136 }137 "adding rules inputs" {138 project.cucumber.suites.register("rulesInputs") {139 it.rules {140 project.cucumber.OK141 }142 it.rulesInputProperties.put("foo", "bar")143 it.rulesInputFiles.from("spec.txt")144 }145 val task = project.tasks.named(cucumberCheckResultsTaskName("rulesInputs"), CucumberCheckResults::class.java).get()146 task.rulesInputProperties.get() shouldContain ("foo" to "bar")147 task.rulesInputFiles shouldContain project.file("spec.txt")148 }149 }150 "Adding the 'java' plugin causes suites to inherit the 'main' source set" {151 val project = testProject()152 project.plugins.apply(GradlecumberPlugin::class.java)153 val suite = project.cucumber.suites.create("dummySuite")154 project.plugins.apply("java")155 suite.inheritsSourceSet shouldContain project.sourceSets.getByName("main")156 }157 }158 "${GradlecumberPlugin::class.simpleName} Task Dependencies" - {159 "Given a project containing a suite without custom rules" - {160 val projectDir = tempdir().projectStruct {161 createSettingsFile()162 createBuildFile().writeText("""163 plugins {164 id("$BASE_PLUGIN_ID")165 }166 167 import ${GradlecumberPlugin::class.java.`package`.name}.*168 169 val featureTest by cucumber.suites.registering170 // Disable tasks, so they just show as skipped171 tasks.all {172 enabled = false173 }174 """.trimIndent())175 }176 val gradleRunner = GradleRunner.create()177 .withPluginClasspath()178 .withProjectDir(projectDir)179 "executing cucumber depends on building the corresponding source set" {180 val tasks = gradleRunner.withArguments("cucumberFeatureTest").build().taskPaths(SKIPPED)181 tasks shouldContainInOrder listOf(":featureTestClasses", ":cucumberFeatureTest")182 }183 "cucumber lifecycle depends on executing cucumber" {184 val tasks = gradleRunner.withArguments("--stacktrace", "featureTest").build().taskPaths(SKIPPED)185 tasks shouldContainInOrder listOf(":cucumberFeatureTest", ":featureTest")186 }187 "check depends on cucumber lifecycle" {188 val tasks = gradleRunner.withArguments("check").build().taskPaths(SKIPPED)189 tasks shouldContainInOrder listOf(":featureTest", ":check")190 }191 }192 "Given a project containing a suite with custom rules" - {193 val projectDir = tempdir().projectStruct {194 createSettingsFile()195 createBuildFile().writeText("""196 plugins {197 id("$BASE_PLUGIN_ID")198 }199 200 import ${GradlecumberPlugin::class.java.`package`.name}.*201 202 val featureTest by cucumber.suites.registering {203 rules { "Dummy" }204 }205 // Disable tasks, so they just show as skipped206 tasks.all {207 enabled = false208 }209 """.trimIndent())210 }211 val gradleRunner = GradleRunner.create()212 .withPluginClasspath()213 .withProjectDir(projectDir)214 "checking results depends on executing cucumber" {215 val tasks = gradleRunner.withArguments("checkCucumberResultsFeatureTest").build().taskPaths(SKIPPED)216 tasks shouldContainInOrder listOf(":cucumberFeatureTest", ":checkCucumberResultsFeatureTest")217 }218 "cucumber lifecycle depends on checking results" {219 val tasks = gradleRunner.withArguments("featureTest").build().taskPaths(SKIPPED)220 tasks shouldContainInOrder listOf(":checkCucumberResultsFeatureTest", ":featureTest")221 }222 }223 "Given a project containing a suite that inherits another source set" - {224 val projectDir = tempdir().projectStruct {225 createSettingsFile()226 createBuildFile().writeText("""227 plugins {228 id("$BASE_PLUGIN_ID")229 }230 231 import ${GradlecumberPlugin::class.java.`package`.name}.*232 233 val foo by sourceSets.creating234 val bar by sourceSets.creating235 236 dependencies {237 "fooRuntimeOnly"(bar.output)238 }239 240 val featureTest by cucumber.suites.registering {241 inheritsSourceSet.add(foo)242 }243 // Disable tasks, so they just show as skipped244 tasks.all {245 enabled = false246 }247 """.trimIndent())248 }249 val gradleRunner = GradleRunner.create()250 .withPluginClasspath()251 .withProjectDir(projectDir)252 "compiling the suite depends on compiling the other source set" {253 val tasks = gradleRunner.withArguments("compileFeatureTestJava").build().taskPaths(SKIPPED)254 tasks shouldContainInOrder listOf(":fooClasses", ":compileFeatureTestJava")255 tasks shouldNotContain ":barClasses"256 }257 "running cucumber depends on compiling the other source set's runtime dependencies" {258 val tasks = gradleRunner.withArguments("cucumberFeatureTest").build().taskPaths(SKIPPED)259 tasks shouldContainInOrder listOf(":barClasses", ":cucumberFeatureTest")260 }261 }262 "Given a project applying the 'java' plugin and containing a suite " - {263 val projectDir = tempdir().projectStruct {264 createSettingsFile()265 createBuildFile().writeText("""266 plugins {267 `java`268 id("$BASE_PLUGIN_ID")269 }270 271 import ${GradlecumberPlugin::class.java.`package`.name}.*272 273 val featureTest by cucumber.suites.registering274 // Disable tasks, so they just show as skipped275 tasks.all {276 enabled = false277 }278 """.trimIndent())279 }280 val gradleRunner = GradleRunner.create()281 .withPluginClasspath()282 .withProjectDir(projectDir)283 "compiling the suite depends on compiling the other main set" {284 val tasks = gradleRunner.withArguments("compileFeatureTestJava").build().taskPaths(SKIPPED)285 tasks shouldContainInOrder listOf(":classes", ":compileFeatureTestJava")286 }287 }288 "Given a project applying the 'java' plugin, containing a suite explicitly set not to inherit from other source sets" - {289 val projectDir = tempdir().projectStruct {290 createSettingsFile()291 createBuildFile().writeText("""292 plugins {293 `java`294 id("$BASE_PLUGIN_ID")295 }296 297 import ${GradlecumberPlugin::class.java.`package`.name}.*298 299 val featureTest by cucumber.suites.registering {300 inheritsSourceSet.clear()301 }302 // Disable tasks, so they just show as skipped303 tasks.all {304 enabled = false305 }306 """.trimIndent())307 }308 val gradleRunner = GradleRunner.create()309 .withPluginClasspath()310 .withProjectDir(projectDir)311 "running cucumber does not depend on compiling main" {312 val tasks = gradleRunner.withArguments("--stacktrace", "cucumberFeatureTest").build().taskPaths(SKIPPED)313 tasks shouldNotContain ":classes"314 }315 }316 }317})...
ExtensionKtIT.kt
Source:ExtensionKtIT.kt
1package ru.iopump.koproc2import io.kotest.assertions.asClue3import io.kotest.core.spec.style.StringSpec4import io.kotest.matchers.nulls.shouldBeNull5import io.kotest.matchers.shouldBe6import io.kotest.matchers.string.shouldBeBlank7import io.kotest.matchers.string.shouldContain8import io.kotest.matchers.string.shouldNotBeBlank9import io.kotest.matchers.types.shouldBeInstanceOf10import kotlinx.coroutines.delay11import org.junit.jupiter.api.assertThrows12import org.slf4j.LoggerFactory13import java.net.ConnectException14import java.net.HttpURLConnection15import java.net.URL16import java.nio.file.Paths17@Suppress("BlockingMethodInNonBlockingContext")18class ExtensionKtIT : StringSpec() {19 private companion object {20 private val log = LoggerFactory.getLogger("koproc")21 }22 init {23 "Java process should started by 'startProcess', provide http access and stopped by 'close' method" {24 val jarPath = Paths.get(this::class.java.getResource("/koproc-sample.jar").toURI())25 val jarAccessUrl = URL("http://localhost:8000/test")26 val koproc = "java -jar $jarPath".startProcess { timeoutSec = 5 }27 koproc.use {28 delay(500)29 log.info("[TEST] Call: $it")30 with(jarAccessUrl.openConnection() as HttpURLConnection) {31 responseCode shouldBe 20032 inputStream.bufferedReader().readText() shouldBe "OK"33 }34 it.readAvailableOut.shouldNotBeBlank()35 log.info("[TEST] Out: ${it.readAvailableOut}")36 }37 assertThrows<ConnectException> {38 with(jarAccessUrl.openConnection() as HttpURLConnection) {39 responseCode shouldBe 40440 }41 }42 koproc.result.out.shouldNotBeBlank()43 log.info("[TEST] Result: ${koproc.result}")44 }45 "Java process should started by 'startProcess' and closed after timeout with the 'KoprocResult'" {46 val jarPath = Paths.get(this::class.java.getResource("/koproc-sample.jar").toURI())47 val koproc = "java -jar $jarPath".startProcess { timeoutSec = 1 }48 koproc.use { call ->49 delay(500)50 log.info("[TEST] Result: ${call.result}")51 call.result.asClue {52 it.code shouldBe 153 it.error.shouldBeInstanceOf<IllegalThreadStateException>()54 it.out.shouldNotBeBlank()55 it.errorOut.shouldBeBlank()56 }57 }58 }59 "Java should display version by 'startCommand' with exit code 0" {60 val koproc = "java -version".startCommand { timeoutSec = 5 }61 log.info("$koproc")62 koproc.asClue {63 it.code shouldBe 064 it.error.shouldBeNull()65 (it.out + it.errorOut).shouldContain("version") // Java may print to out or err66 }67 }68 "Shell or Cmd should print dirs" {69 val os = System.getProperty("os.name").toLowerCase()70 val cmd = if (os.contains("win")) Paths.get(this::class.java.getResource("/cmd.bat").toURI())71 else "pwd"72 val koproc = "$cmd".startCommand { timeoutSec = 5 }73 koproc.asClue {74 it.code shouldBe 075 it.error.shouldBeNull()76 it.out.shouldNotBeBlank()77 it.errorOut.shouldBeBlank()78 }79 }80 "Fail start process" {81 assertThrows<RuntimeException> {82 "error".startCommand().throwOnAnyFailure()83 }84 }85 "Closing after success execution and get the result after closing" {86 val koproc = "java -version".startProcess { timeoutSec = 5 }87 koproc.use {88 it.waitResult()89 }90 koproc.result.asClue {91 it.code shouldBe 092 it.out.shouldBeBlank()93 it.errorOut.shouldNotBeBlank()94 it.error.shouldBeNull()95 it.throwOnUnSuccessCode()96 it.throwOnError()97 it.throwOnAnyFailure()98 }99 }100 "Default timeout [bug in 1.1.0]" {101 koprocDefaultStartCommandTimeoutSec = 1102 val jarPath = Paths.get(this::class.java.getResource("/koproc-sample.jar").toURI())103 "java -jar $jarPath".startCommand()104 koprocDefaultStartProcessTimeoutSec = 1105 "java -jar $jarPath".startProcess().result106 }107 }108}...
FileSystemServiceImplTest.kt
Source:FileSystemServiceImplTest.kt
1package org.factcast.schema.registry.cli.fs2import com.fasterxml.jackson.databind.JsonNode3import io.kotest.core.spec.style.StringSpec4import io.kotest.core.test.TestCase5import io.kotest.core.test.TestResult6import io.kotest.matchers.collections.shouldContain7import io.kotest.matchers.collections.shouldHaveSize8import io.kotest.matchers.shouldBe9import io.kotest.matchers.string.shouldContain10import io.kotest.matchers.string.shouldNotContain11import io.kotest.matchers.types.shouldBeInstanceOf12import org.factcast.schema.registry.cli.fixture13import java.nio.file.Files14import java.nio.file.Paths15class FileSystemServiceImplTest : StringSpec() {16 var tmp = Files.createTempDirectory("fc-test")17 val uut = FileSystemServiceImpl()18 override fun afterTest(testCase: TestCase, result: TestResult) {19 try {20 Files.delete(tmp)21 } catch (e: Exception) {22 } finally {23 tmp = Files.createTempDirectory("fx-test")24 }25 }26 init {27 "exists" {28 uut.exists(fixture("schema.json")) shouldBe true29 uut.exists(fixture("nope.json")) shouldBe false30 }31 "listDirectories" {32 uut.listDirectories(fixture("")) shouldContain fixture("sample-folder")33 uut.listDirectories(fixture("sample-folder")) shouldHaveSize 034 }35 "listFiles" {36 val files = uut.listFiles(fixture(""))37 files shouldHaveSize 138 files shouldContain fixture("schema.json")39 }40 "ensureDirectories" {41 val outputPath = Paths.get(tmp.toString(), "foo")42 uut.ensureDirectories(outputPath)43 uut.exists(outputPath) shouldBe true44 }45 "writeToFile" {46 val outputPath = Paths.get(tmp.toString(), "test.txt")47 uut.writeToFile(outputPath.toFile(), "bar")48 uut.exists(outputPath) shouldBe true49 }50 "readToString" {51 uut.readToString(fixture("schema.json").toFile()) shouldContain "firstName"52 }53 "readToStrings" {54 val output = uut.readToStrings(fixture("schema.json").toFile())55 output[1] shouldContain "additionalProperties"56 output[8] shouldContain "required"57 }58 "copyFile" {59 val outputPath = Paths.get(tmp.toString(), "schema.json")60 uut.copyFile(fixture("schema.json").toFile(), outputPath.toFile())61 uut.exists(outputPath)62 }63 "readToJsonNode" {64 uut.readToJsonNode(fixture("schema.json")).shouldBeInstanceOf<JsonNode>()65 uut.readToJsonNode(fixture("nope.json")) shouldBe null66 }67 "deleteDirectory" {68 uut.exists(tmp) shouldBe true69 uut.deleteDirectory(tmp)70 uut.exists(tmp) shouldBe false71 }72 "readToBytes" {73 val exampleFile = fixture("schema.json")74 uut.readToBytes(exampleFile) shouldBe uut.readToString(exampleFile.toFile()).toByteArray()75 }76 "copyDirectory" {77 val outputPath = Paths.get(tmp.toString(), "foo")78 uut.exists(outputPath) shouldBe false79 uut.copyDirectory(fixture(""), outputPath)80 uut.exists(outputPath) shouldBe true81 }82 "copyFilteredJson" {83 val outputPath = Paths.get(tmp.toString(), "test.txt")84 uut.copyFilteredJson(85 fixture("schema.json").toFile(),86 outputPath.toFile(),87 setOf("title")88 )89 uut.exists(outputPath) shouldBe true90 uut.readToString(outputPath.toFile()) shouldNotContain "title"91 }92 }93}...
specs.kt
Source:specs.kt
...20import io.kotest.core.spec.style.WordSpec21import io.kotest.core.test.TestStatus22import io.kotest.core.test.TestType23import io.kotest.matchers.and24import io.kotest.matchers.paths.aFile25import io.kotest.matchers.paths.beReadable26import io.kotest.matchers.paths.exist27import io.kotest.matchers.should28import org.gradle.testkit.runner.BuildResult29import org.gradle.testkit.runner.GradleRunner30import java.io.File31import java.nio.charset.Charset32abstract class FunctionalSpec(private val suffix: String = "gradle") : WordSpec() {33 lateinit var testProjectDir: File34 lateinit var testkitDir: File35 lateinit var propertiesFile: File36 lateinit var settingsFile: File37 lateinit var buildFile: File38 init {39 beforeTest {40 if (it.type !== TestType.Test) {...
LangTest.kt
Source:LangTest.kt
...9import io.kotest.inspectors.forAll10import io.kotest.matchers.collections.shouldBeIn11import io.kotest.matchers.collections.shouldContainAll12import io.kotest.matchers.collections.shouldHaveAtLeastSize13import io.kotest.matchers.paths.shouldBeReadable14import io.kotest.mpp.log15import java.nio.file.Path16import java.nio.file.Paths17import kotlin.io.path.toPath18class LangTest : FreeSpec({19 val configPath = Paths.get("config/nitron.json")20 NitronConfigLoader.load(configPath).langConfig21 .filter { (_, config) -> config.parserConfig is AntlrParserConfig }22 .forEach { (lang, config) -> include(langTestFactory(lang, config)) }23})24fun langTestFactory(lang: String, config: LangConfig) = freeSpec {25 "config for $lang (${config.fileName})" - {26 val parser = ParserStore.getOrNull(config.parserConfig)27 val parserConfig = config.parserConfig as AntlrParserConfig...
FormatFileTest.kt
Source:FormatFileTest.kt
...4import io.kotest.core.spec.tempfile5import io.kotest.matchers.and6import io.kotest.matchers.collections.beEmpty7import io.kotest.matchers.nulls.beNull8import io.kotest.matchers.paths.aFile9import io.kotest.matchers.paths.beReadable10import io.kotest.matchers.paths.exist11import io.kotest.matchers.should12import io.kotest.matchers.shouldNot13import java.io.File14import java.nio.file.Files15import java.nio.file.Path16import java.nio.file.Paths17import java.nio.file.StandardCopyOption18class FormatFileTest : WordSpec() {19 companion object {20 val LINE_SEPARATOR = System.getProperty("line.separator") ?: "\n";21 }22 private lateinit var actual: File23 private fun resourcePath(name: String): Path {24 val path = this.javaClass.getResource(name)?.let {...
ValidTransformationFolderValidatorTest.kt
Source:ValidTransformationFolderValidatorTest.kt
1package org.factcast.schema.registry.cli.validation.validators.impl2import io.kotest.core.spec.style.StringSpec3import io.kotest.data.forAll4import io.kotest.data.headers5import io.kotest.data.row6import io.kotest.data.table7import io.kotest.matchers.shouldBe8import io.mockk.every9import io.mockk.mockk10import java.nio.file.Paths11import javax.validation.ConstraintValidatorContext12class ValidTransformationFolderValidatorTest : StringSpec() {13 val uut = ValidTransformationFolderValidator()14 val ctx = mockk<ConstraintValidatorContext>()15 init {16 "isValid" {17 every { ctx.defaultConstraintMessageTemplate } returns "foo"18 table(19 headers("path", "validity"),20 row(Paths.get("1-2"), true),21 row(Paths.get("1-v2"), false),22 row(Paths.get("v1-2"), false),23 row(Paths.get("1"), false),24 row(Paths.get("1-2-3"), false)25 ).forAll { path, valid ->26 uut.isValid(path, ctx) shouldBe valid27 }28 }29 }30}...
ValidVersionFolderValidatorTest.kt
Source:ValidVersionFolderValidatorTest.kt
1package org.factcast.schema.registry.cli.validation.validators.impl2import io.kotest.core.spec.style.StringSpec3import io.kotest.data.forAll4import io.kotest.data.headers5import io.kotest.data.row6import io.kotest.data.table7import io.kotest.matchers.shouldBe8import io.mockk.every9import io.mockk.mockk10import java.nio.file.Paths11import javax.validation.ConstraintValidatorContext12class ValidVersionFolderValidatorTest : StringSpec() {13 val uut = ValidVersionFolderValidator()14 val ctx = mockk<ConstraintValidatorContext>()15 init {16 "isValid" {17 every { ctx.defaultConstraintMessageTemplate } returns "foo"18 table(19 headers("path", "validity"),20 row(Paths.get("1"), true),21 row(Paths.get("1.2"), false),22 row(Paths.get("bar"), false)23 ).forAll { path, valid ->24 uut.isValid(path, ctx) shouldBe valid25 }26 }27 }28}...
paths
Using AI Code Generation
1paths {2}3paths {4}5paths {6}7paths {8}9paths {10}11paths {12}13paths {14}15paths {16}17paths {18}19paths {20}21paths {22}23paths {24}25paths {26}27paths {28}29paths {
paths
Using AI Code Generation
1file("foo.txt").shouldNotBeADirectory()2file("foo.txt").shouldNotExist()3file("foo.txt").shouldBeAFile()4file("foo.txt").shouldBeEmpty()5file("foo.txt").shouldBeReadable()6file("foo.txt").shouldBeWritable()7file("foo.txt").shouldHaveExtension("txt")8file("foo.txt").shouldHaveName("foo.txt")9file("foo.txt").shouldHaveTheSameTextualContentAs("bar.txt")10file("foo.txt").shouldHaveTheSameBinaryContentAs("bar.txt")11file("foo.txt").shouldHaveTheSameTextualContentAs(resource("bar.txt"))12file("foo.txt").shouldHaveTheSameBinaryContentAs(resource("bar.txt"))13file("foo.txt").shouldHaveTheSameTextualContentAs(classpath("bar.txt"))14file("foo.txt").shouldHaveTheSameBinaryContentAs(classpath("bar.txt"))15file("foo
paths
Using AI Code Generation
1val path = Paths.get("test.txt")2path should exist()3path should haveExtension("txt")4path should haveName("test.txt")5path should haveParent(".")6path should haveSibling("test.txt")7path should haveSize(0)8path should haveNameStartingWith("test")9path should haveNameEndingWith(".txt")10path should haveNameMatching(Regex("test"))11path should haveNameMatching("test")12path should haveNameNotMatching(Regex("test"))13path should haveNameNotMatching("test")14path should haveNameContaining("est")15path should haveNameNotContaining("est")16path should haveNameNotStartingWith("test")17path should haveNameNotEndingWith(".txt")18path should haveNameNotContaining("est")19path should haveNameNotContaining("est")20path should haveSameContentAs(Paths.get("test.txt"))21path should haveSameTextualContentAs(Paths.get("test.txt"))22path should haveSameBinaryContentAs(Paths.get("test.txt"))23path should beReadable()24path should beWritable()25path should beHidden()26path should beAbsolute()27path should beRelative()28path should beDirectory()29path should beRegularFile()30path should beSymbolicLink()31path should beOther()32path should beExecutable()33path should beReadable()34path should beWritable()35path should beHidden()36path should beAbsolute()37path should beRelative()38path should beDirectory()39path should beRegularFile()40path should beSymbolicLink()41path should beOther()42path should beExecutable()43val path = Paths.get("test.txt")44path shouldNot exist()45path shouldNot haveExtension("txt")46path shouldNot haveName("test.txt")47path shouldNot haveParent(".")48path shouldNot haveSibling("test.txt")49path shouldNot haveSize(0)50path shouldNot haveNameStartingWith("test")51path shouldNot haveNameEndingWith(".txt")52path shouldNot haveNameMatching(Regex("test"))53path shouldNot haveNameMatching("test")54path shouldNot haveNameNotMatching(Regex("test"))55path shouldNot haveNameNotMatching("test")56path shouldNot haveNameContaining("est")57path shouldNot haveNameNotContaining("est")58path shouldNot haveNameNotStartingWith("test")59path shouldNot haveNameNotEndingWith(".txt")60path shouldNot haveNameNotContaining("est")
paths
Using AI Code Generation
1import io.kotest.matchers.paths.*2val path = Paths.get("some/path")3path.shouldBeADirectory()4path.shouldBeAFile()5path.shouldBeRelative()6path.shouldBeAbsolute()7path.shouldBeReadable()8path.shouldBeWritable()9path.shouldExist()10path.shouldHaveExtension("txt")11path.shouldHaveFileName("path")12path.shouldHaveParent(Paths.get("some"))13path.shouldHaveTheSameTextualContentAs(Paths.get("some/other/path"))14path.shouldHaveTheSameBinaryContentAs(Paths.get("some/other/path"))15path.shouldHaveTheSameContentAs(Paths.get("some/other/path"))16path.shouldHaveTheSameLinesAs(Paths.get("some/other/path"))17path.shouldHaveTheSameNormalizedPathAs(Paths.get("some/other/path"))18path.shouldHaveTheSameRealPathAs(Paths.get("some/other/path"))19path.shouldHaveTheSameSizeAs(Paths.get("some/other/path"))20path.shouldHaveTheSameTextualContentAs(Paths.get("some/other/path"))21path.shouldNotBeADirectory()22path.shouldNotBeAFile()23path.shouldNotBeRelative()24path.shouldNotBeAbsolute()25path.shouldNotBeReadable()26path.shouldNotBeWritable()27path.shouldNotExist()28path.shouldNotHaveExtension("txt")29path.shouldNotHaveFileName("path")30path.shouldNotHaveParent(Paths.get("some"))31path.shouldNotHaveTheSameTextualContentAs(Paths.get("some/other/path"))32path.shouldNotHaveTheSameBinaryContentAs(Paths.get("some/other/path"))33path.shouldNotHaveTheSameContentAs(Paths.get("some/other/path"))34path.shouldNotHaveTheSameLinesAs(Paths.get("some/other/path"))35path.shouldNotHaveTheSameNormalizedPathAs(Paths.get("some/other/path"))36path.shouldNotHaveTheSameRealPathAs(Paths.get("some/other/path"))37path.shouldNotHaveTheSameSizeAs(Paths.get("some/other/path"))38path.shouldNotHaveTheSameTextualContentAs(Paths.get("some/other/path"))39import io.kotest.matchers.paths.*40val path = Paths.get("some/path")41path.shouldBeADirectory()42path.shouldBeAFile()43path.shouldBeRelative()44path.shouldBeAbsolute()45path.shouldBeReadable()
paths
Using AI Code Generation
1exists()2existsNot()3isDirectory()4isFile()5isReadable()6isWritable()7isExecutable()8isAbsolute()9isRelative()
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!