How to use test method of io.kotest.matchers.paths.names class

Best Kotest code snippet using io.kotest.matchers.paths.names.test

AbstractDependencyNavigatorTest.kt

Source:AbstractDependencyNavigatorTest.kt Github

copy

Full Screen

...16 * SPDX-License-Identifier: Apache-2.017 * License-Filename: LICENSE18 */19package org.ossreviewtoolkit.model20import io.kotest.core.spec.style.WordSpec21import io.kotest.matchers.collections.beEmpty22import io.kotest.matchers.collections.contain23import io.kotest.matchers.collections.containAll24import io.kotest.matchers.collections.containExactly25import io.kotest.matchers.collections.containExactlyInAnyOrder26import io.kotest.matchers.collections.haveSize27import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder28import io.kotest.matchers.maps.containExactly as containExactlyEntries29import io.kotest.matchers.sequences.beEmpty as beEmptySequence30import io.kotest.matchers.sequences.containExactly as containSequenceExactly31import io.kotest.matchers.should32import io.kotest.matchers.shouldBe33import io.kotest.matchers.shouldNot34import io.kotest.matchers.shouldNotBe35import java.io.File36import java.time.Instant37import org.ossreviewtoolkit.utils.test.readOrtResult38import org.ossreviewtoolkit.utils.test.shouldNotBeNull39/**40 * A base class for tests of concrete [DependencyNavigator] implementations.41 *42 * The class is configured with an ORT result file that contains the expected results in a specific format. It then43 * runs tests on the [DependencyNavigator] of this result and checks whether it returns the correct dependency44 * information.45 */46abstract class AbstractDependencyNavigatorTest : WordSpec() {47 /** The name of the result file to be used by all test cases. */48 protected abstract val resultFileName: String49 /**50 * The name of the file with a result that contains issues. This is used by tests of the collectIssues() function.51 */52 protected abstract val resultWithIssuesFileName: String53 private val testResult by lazy { readOrtResult(resultFileName) }54 private val testProject by lazy { testResult.getProject(PROJECT_ID)!! }55 protected val navigator by lazy { testResult.dependencyNavigator }56 init {57 "scopeNames" should {58 "return the scope names of a project" {59 navigator.scopeNames(testProject) should containExactlyInAnyOrder("compile", "test")60 }61 }62 "directDependencies" should {63 "return the direct dependencies of a project" {64 navigator.directDependencies(testProject, "test").map { it.id } should containSequenceExactly(65 Identifier("Maven:org.scalacheck:scalacheck_2.12:1.13.5"),66 Identifier("Maven:org.scalatest:scalatest_2.12:3.0.4")67 )68 }69 "return an empty sequence for an unknown scope" {70 navigator.directDependencies(testProject, "unknownScope") should beEmptySequence()71 }72 }73 "scopeDependencies" should {74 "return a map with scopes and their dependencies for a project" {75 val scopeDependencies = navigator.scopeDependencies(testProject)76 scopeDependencies.keys should containExactlyInAnyOrder("compile", "test")77 scopeDependencies["compile"] shouldNotBeNull {78 this should haveSize(17)79 this should containAll(80 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),81 Identifier("Maven:org.scala-lang:scala-reflect:2.12.2"),82 Identifier("Maven:org.scala-lang:scala-library:2.12.3")83 )84 }85 scopeDependencies["test"] shouldNotBeNull {86 this should haveSize(6)87 this should containAll(88 Identifier("Maven:org.scalacheck:scalacheck_2.12:1.13.5"),89 Identifier("Maven:org.scalactic:scalactic_2.12:3.0.4")90 )91 }92 }93 "return a map with scopes and their direct dependencies by using maxDepth = 1" {94 val scopeDependencies = navigator.scopeDependencies(testProject, maxDepth = 1)95 scopeDependencies["compile"] shouldNotBeNull {96 this should haveSize(7)97 this shouldNot contain(Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"))98 }99 }100 "return a map with scopes and their dependencies up to a given maxDepth" {101 val scopeDependencies = navigator.scopeDependencies(testProject, maxDepth = 2)102 scopeDependencies["compile"] shouldNotBeNull {103 this should haveSize(14)104 this shouldNot contain(105 Identifier("Maven:org.scala-lang.modules:scala-java8-compat_2.12:0.8.0")106 )107 }108 }109 "return a map with scopes and their dependencies with filter criteria" {110 val matchedIds = mutableSetOf<Identifier>()111 val scopeDependencies = navigator.scopeDependencies(testProject) { node ->112 matchedIds += node.id113 node.id.namespace == "com.typesafe.akka"114 }115 scopeDependencies["compile"] shouldNotBeNull {116 this should containExactlyInAnyOrder(117 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),118 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")119 )120 }121 matchedIds should haveSize(23)122 }123 }124 "dependenciesForScope" should {125 "return an empty set for an unknown scope" {126 navigator.dependenciesForScope(testProject, "unknownScope") should beEmpty()127 }128 "return the dependencies of a specific scope" {129 val compileDependencies = navigator.dependenciesForScope(testProject, "compile")130 compileDependencies should haveSize(17)131 compileDependencies should containAll(132 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),133 Identifier("Maven:org.scala-lang:scala-reflect:2.12.2"),134 Identifier("Maven:org.scala-lang:scala-library:2.12.3")135 )136 }137 "return the dependencies of a specific scope up to a given maxDepth" {138 val compileDependencies = navigator.dependenciesForScope(testProject, "compile", maxDepth = 2)139 compileDependencies should haveSize(14)140 compileDependencies shouldNot contain(141 Identifier("Maven:org.scala-lang.modules:scala-java8-compat_2.12:0.8.0")142 )143 }144 "return the dependencies of a specific scope with filter criteria" {145 val akkaDependencies = navigator.dependenciesForScope(testProject, "compile") { node ->146 "akka" in node.id.namespace147 }148 akkaDependencies.shouldContainExactlyInAnyOrder(149 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),150 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")151 )152 }153 }154 "packageDependencies" should {155 "return the dependencies of an existing package in a project" {156 val pkgId = Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")157 val dependencies = navigator.packageDependencies(testProject, pkgId)158 dependencies should containExactlyInAnyOrder(159 Identifier("Maven:com.typesafe:ssl-config-core_2.12:0.2.2"),160 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),161 Identifier("Maven:org.scala-lang.modules:scala-java8-compat_2.12:0.8.0"),162 Identifier("Maven:org.reactivestreams:reactive-streams:1.0.1")163 )164 }165 "return an empty set for the dependencies of a non-existing package" {166 val pkgId = Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.7")167 val dependencies = navigator.packageDependencies(testProject, pkgId)168 dependencies should beEmpty()169 }170 "support a maxDepth filter" {171 val pkgId = Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")172 val dependencies = navigator.packageDependencies(testProject, pkgId, maxDepth = 1)173 dependencies should containExactlyInAnyOrder(174 Identifier("Maven:com.typesafe:ssl-config-core_2.12:0.2.2"),175 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6"),176 Identifier("Maven:org.reactivestreams:reactive-streams:1.0.1")177 )178 }179 "support a DependencyMatcher" {180 val pkgId = Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")181 val dependencies = navigator.packageDependencies(testProject, pkgId) { node ->182 node.id.namespace.startsWith("com.typesafe")183 }184 dependencies should containExactlyInAnyOrder(185 Identifier("Maven:com.typesafe:ssl-config-core_2.12:0.2.2"),186 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6")187 )188 }189 }190 "getShortestPaths" should {191 "return the shortest paths for a project" {192 val paths = navigator.getShortestPaths(testProject)193 paths.keys should haveSize(2)194 paths["compile"] shouldNotBeNull {195 this should containExactlyEntries(196 Identifier("Maven:ch.qos.logback:logback-classic:1.2.3") to emptyList(),197 Identifier("Maven:ch.qos.logback:logback-core:1.2.3") to listOf(198 Identifier("Maven:ch.qos.logback:logback-classic:1.2.3")199 ),200 Identifier("Maven:com.fasterxml.jackson.core:jackson-annotations:2.8.0") to listOf(201 Identifier("Maven:net.logstash.logback:logstash-logback-encoder:4.11"),202 Identifier("Maven:com.fasterxml.jackson.core:jackson-databind:2.8.9")203 ),204 Identifier("Maven:com.fasterxml.jackson.core:jackson-core:2.8.9") to listOf(205 Identifier("Maven:net.logstash.logback:logstash-logback-encoder:4.11"),206 Identifier("Maven:com.fasterxml.jackson.core:jackson-databind:2.8.9")207 ),208 Identifier("Maven:com.fasterxml.jackson.core:jackson-databind:2.8.9") to listOf(209 Identifier("Maven:net.logstash.logback:logstash-logback-encoder:4.11")210 ),211 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6") to listOf(212 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")213 ),214 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6") to emptyList(),215 Identifier("Maven:com.typesafe:config:1.3.1") to emptyList(),216 Identifier("Maven:com.typesafe.scala-logging:scala-logging_2.12:3.7.2") to emptyList(),217 Identifier("Maven:com.typesafe:ssl-config-core_2.12:0.2.2") to listOf(218 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")219 ),220 Identifier("Maven:net.logstash.logback:logstash-logback-encoder:4.11") to emptyList(),221 Identifier("Maven:org.scala-lang:scala-library:2.12.3") to emptyList(),222 Identifier("Maven:org.scala-lang:scala-reflect:2.12.2") to listOf(223 Identifier("Maven:com.typesafe.scala-logging:scala-logging_2.12:3.7.2")224 ),225 Identifier("Maven:org.scala-lang.modules:scala-java8-compat_2.12:0.8.0") to listOf(226 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6"),227 Identifier("Maven:com.typesafe.akka:akka-actor_2.12:2.5.6")228 ),229 Identifier("Maven:org.reactivestreams:reactive-streams:1.0.1") to listOf(230 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6")231 ),232 Identifier("Maven:org.slf4j:jcl-over-slf4j:1.7.25") to emptyList(),233 Identifier("Maven:org.slf4j:slf4j-api:1.7.25") to listOf(234 Identifier("Maven:ch.qos.logback:logback-classic:1.2.3")235 ),236 )237 }238 }239 }240 "projectDependencies" should {241 "return the dependencies of a project" {242 val scopeDependencies = navigator.scopeDependencies(testProject)243 val projectDependencies = navigator.projectDependencies(testProject)244 scopeDependencies.keys should containExactlyInAnyOrder("compile", "test")245 val expectedDependencies = scopeDependencies.getValue("compile") + scopeDependencies.getValue("test")246 projectDependencies should containExactlyInAnyOrder(expectedDependencies)247 }248 "support filtering the dependencies of a project" {249 val dependencies = navigator.projectDependencies(testProject, 1) {250 it.linkage != PackageLinkage.PROJECT_DYNAMIC251 }252 dependencies should containExactlyInAnyOrder(253 Identifier("Maven:ch.qos.logback:logback-classic:1.2.3"),254 Identifier("Maven:com.typesafe:config:1.3.1"),255 Identifier("Maven:com.typesafe.akka:akka-stream_2.12:2.5.6"),256 Identifier("Maven:com.typesafe.scala-logging:scala-logging_2.12:3.7.2"),257 Identifier("Maven:net.logstash.logback:logstash-logback-encoder:4.11"),258 Identifier("Maven:org.scala-lang:scala-library:2.12.3"),259 Identifier("Maven:org.slf4j:jcl-over-slf4j:1.7.25"),260 Identifier("Maven:org.scalacheck:scalacheck_2.12:1.13.5"),261 Identifier("Maven:org.scalatest:scalatest_2.12:3.0.4")262 )263 }264 "return no dependencies for a maxDepth of 0" {265 val dependencies = navigator.projectDependencies(testProject, 0)266 dependencies should beEmpty()267 }268 }269 "collectSubProjects" should {270 "find all the sub projects of a project" {271 val projectId = Identifier("SBT:com.pbassiner:multi1_2.12:0.1-SNAPSHOT")272 testResult.getProject(projectId) shouldNotBeNull {273 val subProjectIds = navigator.collectSubProjects(this)274 subProjectIds should containExactly(PROJECT_ID)275 }276 }277 }278 "dependencyTreeDepth" should {279 "calculate the dependency tree depth for a project" {280 navigator.dependencyTreeDepth(testProject, "compile") shouldBe 3281 navigator.dependencyTreeDepth(testProject, "test") shouldBe 2282 }283 "return 0 if the scope cannot be resolved" {284 navigator.dependencyTreeDepth(testProject, "unknownScope") shouldBe 0285 }286 }287 "projectIssues" should {288 "return the issues of a project" {289 val ortResultWithIssues = File(resultWithIssuesFileName).readValue<OrtResult>()290 val project = ortResultWithIssues.analyzer?.result?.projects.orEmpty().first()291 val navigator = ortResultWithIssues.dependencyNavigator292 val issues = navigator.projectIssues(project)293 issues should containExactlyEntries(294 Identifier("Maven:org.scala-lang.modules:scala-java8-compat_2.12:0.8.0") to setOf(295 OrtIssue(296 Instant.EPOCH,297 "Gradle",298 "Test issue 1"299 )300 ),301 Identifier("Maven:org.scalactic:scalactic_2.12:3.0.4") to setOf(302 OrtIssue(303 Instant.EPOCH,304 "Gradle",305 "Test issue 2"306 )307 )308 )309 }310 }311 "DependencyNode.equals" should {312 "be reflexive" {313 val node = navigator.directDependencies(testProject, "compile").iterator().next()314 node shouldBe node315 }316 "return false for a different node" {317 val iterator = navigator.directDependencies(testProject, "compile").iterator()318 val node1 = iterator.next().getStableReference()319 val node2 = iterator.next()320 node1 shouldNotBe node2321 }322 "return true the same node" {323 val node1 = navigator.directDependencies(testProject, "compile").iterator().next()324 .getStableReference()325 val node2 = navigator.directDependencies(testProject, "compile").iterator().next()326 .getStableReference()327 node1 shouldBe node2328 node1.hashCode() shouldBe node2.hashCode()329 }330 "return false for another object" {331 val node = navigator.directDependencies(testProject, "compile").iterator().next()332 node shouldNotBe this333 }334 }335 }336}337/** Identifier of the project used by the tests. */338private val PROJECT_ID = Identifier("SBT:com.pbassiner:common_2.12:0.1-SNAPSHOT")...

Full Screen

Full Screen

GDriveDirectClientSpec.kt

Source:GDriveDirectClientSpec.kt Github

copy

Full Screen

1package com.ziemsky.uploader.test.integration2import com.google.api.client.http.FileContent3import com.google.api.services.drive.Drive4import com.ziemsky.fsstructure.FsStructure.*5import com.ziemsky.uploader.securing.infrastructure.googledrive.GDriveDirectClient6import com.ziemsky.uploader.securing.infrastructure.googledrive.GDriveRetryingClient7import com.ziemsky.uploader.securing.infrastructure.googledrive.model.GDriveFolder8import com.ziemsky.uploader.securing.model.local.LocalFile9import com.ziemsky.uploader.securing.model.remote.RemoteDailyFolder10import com.ziemsky.uploader.test.integration.config.IntegrationTestConfig11import com.ziemsky.uploader.test.shared.data.TestFixtures12import io.kotest.core.spec.IsolationMode13import io.kotest.core.spec.style.BehaviorSpec14import io.kotest.matchers.Matcher15import io.kotest.matchers.MatcherResult16import io.kotest.matchers.should17import io.kotest.matchers.shouldBe18import org.springframework.test.context.ContextConfiguration19import java.nio.file.Path20import java.nio.file.Paths21import java.time.Duration22import java.time.LocalDate23@ContextConfiguration(classes = [(IntegrationTestConfig::class)])24class GDriveDirectClientSpec(val drive: Drive,25 val testFixtures: TestFixtures,26 testDirectory: Path27) : BehaviorSpec() {28 override fun isolationMode(): IsolationMode? = IsolationMode.InstancePerLeaf29 lateinit var gDriveClient: GDriveRetryingClient30 // todo consider slimming down pre-existing remote folder structure - too many unnecessary items to create, too much time wasted? different set for different tests?31 init {32 Given("a remote structure of daily folders exist") {33 val rootFolder = testInitialisedAndDriveCreated()34 testFixtures.remoteStructureCreateFrom(rootFolder.id, create(35 dir("2018-09-01",36 fle("nested file"),37 dir("nested dir"),38 dir("2018-09-05")),39 dir("2018-09-02",40 fle("nested file"),41 dir("nested dir"),42 dir("2018-09-06")),43 dir("2018-09-03",44 fle("nested file"),45 dir("nested dir"),46 dir("2018-09-07")),47 dir("mis-matching folder",48 fle("another nested file"),49 dir("another nested dir"),50 dir("2018-09-08")),51 fle("2018-09-04"),52 fle("mis-matching top-level file")53 ))54 When("retrieving child folders of given folder") {55 val actualFolders = gDriveClient.childFoldersOf(rootFolder)56 Then("returns existing top level folders") {57 actualFolders should containExactlyFoldersWithIdsInAnyOrder(58 "2018-09-01",59 "2018-09-02",60 "2018-09-03"61 )62 }63 }64 When("removing an existing folder") {65 val targetFolderName = "2018-09-01"66 val targetFolderId = testFixtures.findChildFolderIdByName(rootFolder.id, targetFolderName)67 gDriveClient.deleteFolder(GDriveFolder(targetFolderName, targetFolderId!!))68 Then("deletes requested folder with its content, leaving other content intact, and updates local cache") {69 testFixtures.remoteStructureWithin(rootFolder.id) shouldBe create(70 dir("2018-09-02",71 fle("nested file"),72 dir("nested dir"),73 dir("2018-09-06")),74 dir("2018-09-03",75 fle("nested file"),76 dir("nested dir"),77 dir("2018-09-07")),78 dir("mis-matching folder",79 fle("another nested file"),80 dir("another nested dir"),81 dir("2018-09-08")),82 fle("2018-09-04"),83 fle("mis-matching top-level file")84 )85 }86 }87 When("creating new folder with given name as a child of another folder") {88 val expectedFolderName = "2020-12-10"89 val actualGDriveFolder = gDriveClient.createTopLevelFolder(rootFolder.id, expectedFolderName)90 Then("new remote folder gets created alongside existing ones") {91 testFixtures.remoteStructureWithin(rootFolder.id) shouldBe create(92 dir(expectedFolderName), // newly added folder93 dir("2018-09-01",94 fle("nested file"),95 dir("nested dir"),96 dir("2018-09-05")),97 dir("2018-09-02",98 fle("nested file"),99 dir("nested dir"),100 dir("2018-09-06")),101 dir("2018-09-03",102 fle("nested file"),103 dir("nested dir"),104 dir("2018-09-07")),105 dir("mis-matching folder",106 fle("another nested file"),107 dir("another nested dir"),108 dir("2018-09-08")),109 fle("2018-09-04"),110 fle("mis-matching top-level file")111 )112 actualGDriveFolder.name shouldBe expectedFolderName113 }114 }115 }116 Given("a single file to upload") {117 val rootFolder = testInitialisedAndDriveCreated()118 val testFileName = "20180901120000-00-front.jpg"119 val targetFolder = RemoteDailyFolder.from(LocalDate.of(2018, 9, 1))120 val expectedStructure = create(121 dir(targetFolder.name.toString(),122 fle(testFileName)123 )124 )125 testFixtures.localStructureCreateFrom(create(fle(testFileName)))126 val localFile = LocalFile(Paths.get(testDirectory.toString(), testFileName).toFile())127 And("existing, corresponding daily folder") {128 testFixtures.remoteStructureCreateFrom(rootFolder.id, create(129 dir(targetFolder.name.toString())130 ))131 val existingDailyFolderId = testFixtures.findChildFolderIdByName(rootFolder.id, targetFolder.name.toString())132 val gDriveFile = com.google.api.services.drive.model.File()133 gDriveFile.name = localFile.nameLocal.raw134 gDriveFile.parents = listOf(existingDailyFolderId)135 val mediaContent = FileContent(null, localFile.raw)136 When("uploading the file") {137 gDriveClient.upload(gDriveFile, mediaContent)138 Then("the file is uploaded to the existing daily folder") {139 testFixtures.remoteStructure(rootFolder.id) shouldBe expectedStructure140 }141 }142 }143 }144 }145 private fun containExactlyFoldersWithIdsInAnyOrder(vararg expectedFolderNames: String) = object: Matcher<List<GDriveFolder>> {146 override fun test(actualFolders: List<GDriveFolder>): MatcherResult {147 val actualFolderIdsList = actualFolders.map(GDriveFolder::name).sorted()148 val expectedFoldersNamesList = expectedFolderNames.asList().sorted()149 return MatcherResult (150 actualFolderIdsList == expectedFoldersNamesList,151 "Should contain folders with names $expectedFoldersNamesList but was $actualFolderIdsList",152 "Should not contain folders with names: $expectedFoldersNamesList but was $actualFolderIdsList"153 )154 }155 }156 private fun testInitialisedAndDriveCreated(): GDriveFolder {157 testFixtures.localTestContentDelete()158 testFixtures.remoteStructureDelete()159 val rootFolder = testFixtures.createRootFolder("rootFolder")160 gDriveClient = GDriveRetryingClient(GDriveDirectClient(drive), Duration.ofMinutes(1))161 return rootFolder162 }163}...

Full Screen

Full Screen

CandidKtPluginSpec.kt

Source:CandidKtPluginSpec.kt Github

copy

Full Screen

1package com.github.seniorjoinu.candid.plugin2import io.kotest.core.spec.IsolationMode3import io.kotest.core.spec.style.FreeSpec4import io.kotest.matchers.file.shouldExist5import io.kotest.matchers.file.shouldNotHaveFileSize6import io.kotest.matchers.shouldBe7import io.kotest.matchers.string.shouldContain8import org.gradle.internal.impldep.org.junit.rules.TemporaryFolder9import org.gradle.testkit.runner.BuildResult10import org.gradle.testkit.runner.GradleRunner11import org.gradle.testkit.runner.TaskOutcome12import java.io.File13import java.io.PrintWriter14import java.nio.file.Paths15import java.util.Locale16/**17 * System under specification: {@link CandidKtPlugin}; strictly speaking this a functional test, although it was added to the unit test source set.18 */19class CandidKtPluginSpec : FreeSpec({20 isolationMode = IsolationMode.InstancePerLeaf21 val didName = "greet"22 val packageName = "tld.d.etc"23 "given a project dir" - {24 val projectDir = TemporaryFolder()25 projectDir.create()26 "and the plugin is applied" - {27 val buildFile = projectDir.newFile("build.gradle")28 buildFile.writeText("""29 plugins {30 id 'com.github.seniorjoinu.candid'31 }32 candid {33 sourceSets {34 test35 }36 }37 """.trimIndent())38 buildFile.appendText(System.lineSeparator())39 "positive executing 'gradle tasks'" {40 val taskName = "tasks"41 val arguments = listOf(taskName)42 val result = build(projectDir.root, arguments)43 result.task(":$taskName")?.outcome shouldBe TaskOutcome.SUCCESS44 result.output shouldContain "${CANDID_GROUP_NAME.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }} tasks"45 result.output shouldContain "$CANDID_TASK_NAME - Generates Kotlin sources from Candid language files resolved from the 'main' Candid source set."46 result.output shouldContain "generateTestCandid - Generates Kotlin sources from Candid language files resolved from the 'test' Candid source set."47 }48 "positive executing 'gradle help --task generateCandid'" {49 val taskName = "help"50 val arguments = listOf(taskName, "--task", CANDID_TASK_NAME)51 val result = build(projectDir.root, arguments)52 result.task(":$taskName")?.outcome shouldBe TaskOutcome.SUCCESS53 result.output shouldContain "Detailed task information for $CANDID_TASK_NAME"54 result.output shouldContain "Path${System.lineSeparator()} :$CANDID_TASK_NAME"55 result.output shouldContain "Description${System.lineSeparator()} Generates Kotlin sources from Candid language files resolved from the 'main' Candid source set."56 result.output shouldContain "Group${System.lineSeparator()} $CANDID_GROUP_NAME"57 }58 "positive executing 'gradle generateCandid' with defaults" {59 val didFile = createDidFile(projectDir.root, didName, "src", "main", "candid")60 val ktFile = Paths.get(projectDir.root.canonicalPath, "build/$CANDID_DESTINATION_PREFIX_KOTLIN/main", "${didName}.did.kt").toFile()...

Full Screen

Full Screen

CacheTests.kt

Source:CacheTests.kt Github

copy

Full Screen

...21@file:Suppress("EXPERIMENTAL_API_USAGE")22import com.meowool.gradle.toolkit.internal.DependencyMapperExtensionImpl23import com.meowool.gradle.toolkit.internal.DependencyMapperInternal.CacheDir24import com.meowool.gradle.toolkit.internal.DependencyMapperInternal.CacheJarsDir25import io.kotest.assertions.forEachAsClue26import io.kotest.core.spec.style.StringSpec27import io.kotest.engine.spec.tempdir28import io.kotest.matchers.shouldBe29import io.kotest.matchers.string.shouldStartWith30import org.gradle.testfixtures.ProjectBuilder31/**32 * @author 凛 (RinOrz)33 */34class CacheTests : StringSpec({35 val project = ProjectBuilder.builder().withProjectDir(tempdir()).build()36 val dependencyMapper = DependencyMapperExtensionImpl(project).apply {37 val p = plugins("PluginMapped")38 libraries("Libraries") {39 transferPluginIds(p)40 map("foo:bar", "a.B.C:dd")41 map(42 "com.foo.bar:v" to "Foo",43 "test:test.plugin" to "Test.Plugin"44 )45 searchDefaultOptions {46 filter { true }47 }48 search("meowool")49 searchGroups("com.google.android") {50 fromGoogle()51 filter { false }52 }53 searchPrefixes("org.jetbrains.anko", "org.apache.avro") {54 fromMavenCentral()55 fromGradlePluginPortal()56 }57 }...

Full Screen

Full Screen

LangTest.kt

Source:LangTest.kt Github

copy

Full Screen

1package com.github.durun.nitron.test2import com.github.durun.nitron.core.config.AntlrParserConfig3import com.github.durun.nitron.core.config.LangConfig4import com.github.durun.nitron.core.config.loader.NitronConfigLoader5import com.github.durun.nitron.core.parser.antlr.ParserStore6import io.kotest.assertions.throwables.shouldNotThrowAny7import io.kotest.core.spec.style.FreeSpec8import io.kotest.core.spec.style.freeSpec9import 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 AntlrParserConfig28 "grammar files exist" {...

Full Screen

Full Screen

AllureTestReporterTest.kt

Source:AllureTestReporterTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest2import com.fasterxml.jackson.databind.JsonNode3import com.fasterxml.jackson.databind.ObjectMapper4import com.fasterxml.jackson.databind.node.ArrayNode5import com.fasterxml.jackson.module.kotlin.KotlinModule6import io.kotest.core.spec.Order7import io.kotest.core.spec.style.WordSpec8import io.kotest.inspectors.forOne9import io.kotest.matchers.shouldBe10import java.nio.file.Paths11// this must have a higher order number than the dummy tests12// so that when we get to this test, we have some data13@Order(1)14class AllureTestReporterTest : WordSpec() {15 private val mapper = ObjectMapper().registerModule(KotlinModule())16 private fun findTestFile(name: String): JsonNode {17 val names = Paths.get("./build/allure-results").toFile().listFiles()18 .filter { it.name.endsWith(".json") }19 .map { mapper.readTree(it) }20 .map { it.get("name").textValue() }21 return Paths.get("./build/allure-results").toFile().listFiles()22 .filter { it.name.endsWith(".json") }23 .map { mapper.readTree(it) }24 .first { it.get("name").textValue() == name }25 }26 init {27 "AllureTestReporter" should {28 "write out data" {29 val json = findTestFile("Given: a given When: another when Then: a final then")30 json["name"].textValue() shouldBe "Given: a given When: another when Then: a final then"31 json["fullName"].textValue() shouldBe "Given: a given When: another when Then: a final then"32 val labels = json.get("labels") as ArrayNode33 labels.toList().forOne {34 it["name"].asText() shouldBe "suite"35 it["value"].textValue() shouldBe "com.sksamuel.kotest.DummyBehaviorSpecTest"36 }37 labels.toList().forOne {38 it["name"].textValue() shouldBe "language"39 it["value"].textValue() shouldBe "kotlin"40 }41 labels.toList().forOne {42 it["name"].textValue() shouldBe "framework"43 it["value"].textValue() shouldBe "kotest"44 }45 labels.toList().forOne {46 it["name"].textValue() shouldBe "epic"47 it["value"].textValue() shouldBe "my epic"48 }49 labels.toList().forOne {50 it["name"].textValue() shouldBe "package"51 it["value"].textValue() shouldBe "com.sksamuel.kotest"52 }53 }54 "set correct historyId" {55 val json = findTestFile("context a should work")56 json["historyId"].textValue() shouldBe "com.sksamuel.kotest.DummyShouldSpec/context a -- work"57 }58 "set correct testCaseId" {59 val json = findTestFile("context a should work")60 json["testCaseId"].textValue() shouldBe "com.sksamuel.kotest.DummyShouldSpec/context a -- work"61 }62 "set correct fullName" {63 val json = findTestFile("context a should work")64 json["fullName"].textValue() shouldBe "context a should work"65 }66 }67 }68}...

Full Screen

Full Screen

IOSpec.kt

Source:IOSpec.kt Github

copy

Full Screen

1package com.github.rougsig.core2import io.kotest.core.datatest.forAll3import io.kotest.core.spec.style.FunSpec4import io.kotest.matchers.file.shouldBeADirectory5import io.kotest.matchers.file.shouldBeAFile6import io.kotest.matchers.file.shouldExist7import io.kotest.matchers.shouldBe8import kotlinx.coroutines.runBlocking9import java.io.ByteArrayInputStream10import java.io.ByteArrayOutputStream11import java.io.File12import java.io.PrintStream13import java.nio.file.Paths14abstract class IOSpec(15 private val resourcesPath: String,16 private val testFun: IOEnvironment.() -> Unit17) : FunSpec({18 val projectRoot = File(".").absoluteFile.parent19 val resourcesDir = Paths.get(projectRoot, "src/test/resources", resourcesPath).toFile()20 context("File IO tests") {21 val inputDir = File("${resourcesDir.absoluteFile}/input")22 inputDir.shouldExist()23 inputDir.shouldBeADirectory()24 val outputDir = File("${resourcesDir.absoluteFile}/output")25 outputDir.shouldExist()26 val testNames = inputDir.listFiles()27 .map { it.nameWithoutExtension.removePrefix("input") }28 forAll(testNames) { testName: String ->29 val input = File("${inputDir.absoluteFile}/input${testName}.txt")30 input.shouldExist()31 input.shouldBeAFile()32 val output = File("${outputDir.absoluteFile}/output${testName}.txt")33 output.shouldExist()34 output.shouldBeAFile()35 val baos = ByteArrayOutputStream()36 runBlocking {37 // Set the same as hackerrank timeout limit38 // https://www.hackerrank.com/environment/languages39 withTimeoutOrInterrupt(4000L) {40 IOEnvironment(ByteArrayInputStream(input.readBytes()), PrintStream(baos)).testFun()41 }42 }43 val actual = baos.toString().trim().trimIndent()44 val expected = output.readText().trim().trimIndent()45 actual.shouldBe(expected)46 }47 }48})...

Full Screen

Full Screen

GenericParserTest.kt

Source:GenericParserTest.kt Github

copy

Full Screen

1package com.github.durun.nitron.core.parser.antlr2import com.github.durun.nitron.core.config.AntlrParserConfig3import com.github.durun.nitron.core.config.loader.NitronConfigLoader4import io.kotest.assertions.throwables.shouldNotThrowAny5import io.kotest.core.spec.style.FreeSpec6import io.kotest.core.spec.style.freeSpec7import io.kotest.matchers.collections.shouldHaveAtLeastSize8import java.nio.file.Paths9class GenericParserTest : FreeSpec({10 val configPath = Paths.get("config/nitron.json")11 val config = NitronConfigLoader.load(configPath)12 include(13 tests(14 "javascript",15 config.langConfig["javascript"]!!.parserConfig as AntlrParserConfig,16 src = """console.log("Hello");"""17 )18 )19})20private fun tests(name: String, config: AntlrParserConfig, src: String) = freeSpec {21 val parser = ParserStore.getOrThrow(config)22 name - {23 "init" {24 shouldNotThrowAny {25 println(parser)26 }27 }28 "antlrParser" {29 val antlr = shouldNotThrowAny {30 parser.antlrParser31 }32 antlr.ruleNames shouldHaveAtLeastSize 133 antlr.tokenTypeMap.entries shouldHaveAtLeastSize 134 }...

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1 import io.kotest.matchers.paths.names.shouldHaveFileName2 import io.kotest.matchers.paths.names.shouldHaveName3 import io.kotest.matchers.paths.names.shouldHaveNameIgnoringCase4 import io.kotest.matchers.paths.names.shouldHaveNameStartingWith5 import io.kotest.matchers.paths.names.shouldHaveNameStartingWithIgnoringCase6 import io.kotest.matchers.paths.names.shouldHaveNameEndingWith7 import io.kotest.matchers.paths.names.shouldHaveNameEndingWithIgnoringCase8 import io.kotest.matchers.paths.names.shouldHaveNameContaining9 import io.kotest.matchers.paths.names.shouldHaveNameContainingIgnoringCase10 import io.kotest.matchers.paths.names.shouldHaveNameMatching11 import io.kotest.matchers.paths.names.shouldHaveNameMatchingIgnoringCase12 import io.kotest.matchers.paths.names.shouldHaveNoExtension13 import io.kotest.matchers.paths.names.shouldHaveExtension14 import io.kotest.matchers.paths.names.shouldHaveExtensionIgnoringCase15 import io.kotest.matchers.paths.names.shouldHaveExtensionStartingWith16 import io.kotest.matchers.paths.names.shouldHaveExtensionStartingWithIgnoringCase17 import io.kotest.matchers.paths.names.shouldHaveExtensionEndingWith18 import io.kotest.matchers.paths.names.shouldHaveExtensionEndingWithIgnoringCase19 import io.kotest.matchers.paths.names.shouldHaveExtensionContaining20 import io.kotest.matchers.paths.names.shouldHaveExtensionContainingIgnoringCase21 import io.kotest.matchers.paths.names.shouldHaveExtensionMatching22 import io.kotest.matchers.paths.names.shouldHaveExtensionMatchingIgnoringCase23 import io.kotest.matchers.paths.names.shouldHaveParent24 import io.kotest.matchers.paths.names.shouldHaveParentIgnoringCase25 import io.kotest.matchers.paths.names.shouldHaveParentStartingWith26 import io.kotest.matchers.paths.names.shouldHaveParentStartingWithIgnoringCase27 import io.kotest.matchers.paths.names.shouldHaveParentEndingWith28 import io.kotest.matchers.paths.names.shouldHaveParentEndingWithIgnoringCase29 import io.kotest.matchers.paths.names.shouldHaveParentContaining30 import io.kotest.matchers.paths.names.shouldHaveParentContainingIgnoringCase31 import io.kotest.matchers.paths.names.shouldHaveParentMatching

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1val path = Paths.get( "/home/user/folder" )2val path = Paths.get( "/home/user/folder" )3path.parent shouldBe Paths.get( "/home/user" )4val path = Paths.get( "/home/user/folder" )5path.parent shouldBe Paths.get( "/home/user" )6val path = Paths.get( "/home/user/folder" )7path.parents shouldBe listOf(Paths.get( "/home/user" ), Paths.get( "/home" ), Paths.get( "/" ))8val path = Paths.get( "/home/user/folder" )9val path = Paths.get( "/home/user/folder" )10val path = Paths.get( "/home/user/folder" )11path.startsWith(Paths.get( "/home" )) shouldBe true12val path = Paths.get( "/home/user/folder" )13path.startsWith(Paths.get( "/home" )) shouldBe true14val path = Paths.get( "/home/user/folder" )15path.toFile() shouldBe File( "/home/user/folder" )16val path = Paths.get( "/home/user/folder" )17path.toFile() shouldBe File( "/home/user/folder" )18val path = Paths.get( "/home/user/folder" )19path.toUri() shouldBe URI( "file:/home/user/folder" )20val path = Paths.get( "/home/user/folder" )21path.toUri() shouldBe URI( "file:/home/user/folder

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1 fun `test path names`() {2 val path = Paths.get("/usr/local/bin")3 path should haveFileName("bin")4 path should haveParent(Paths.get("/usr/local"))5 path should haveNameCount(3)6 path should haveName(0, "usr")7 path should haveName(1, "local")8 path should haveName(2, "bin")9 }10 fun `test path`() {11 val path = Paths.get("/usr/local/bin")12 path should haveRoot(Paths.get("/"))13 path should haveRootName("usr")14 path should haveRootDirectory(Paths.get("/"))15 path should haveFileName("bin")16 path should haveParent(Paths.get("/usr/local"))17 path should haveNameCount(3)18 path should haveName(0, "usr")19 path should haveName(1, "local")20 path should haveName(2, "bin")21 }22}23fun Path.shouldHaveRoot(root: Path) = this should haveRoot(root)24fun Path.shouldHaveRootName(rootName: String) = this should haveRootName(rootName)25fun Path.shouldHaveRootDirectory(rootDirectory: Path) = this should haveRootDirectory(rootDirectory)26fun Path.shouldHaveFileName(fileName: String) = this should haveFileName(fileName)27fun Path.shouldHaveParent(parent: Path) = this should haveParent(parent)28fun Path.shouldHaveNameCount(nameCount: Int) = this should haveNameCount(nameCount)29fun Path.shouldHaveName(index: Int, name: String) = this should haveName(index, name)30fun Path.shouldHaveFileName(fileName: String) = this should haveFileName(fileName)31fun Path.shouldHaveParent(parent: Path) = this should haveParent(parent)32fun Path.shouldHaveNameCount(nameCount: Int) = this should haveNameCount(nameCount)33fun Path.shouldHaveName(index: Int, name: String) = this should haveName(index, name)34fun Path.shouldHaveDirectoryCount(count: Int) = this should haveDirectoryCount(count)

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.paths.names2fun test() {3val path = Paths.get("C:/test.txt")4path.names.shouldBe("test.txt")5}6import io.kotest.matchers.paths.parent7fun test() {8val path = Paths.get("C:/test.txt")9path.parent shouldBe Paths.get("C:/")10}11import io.kotest.matchers.paths.parent12fun test() {13val path = Paths.get("C:/test.txt")14path.parent shouldBe Paths.get("C:/")15}16import io.kotest.matchers.paths.parent17fun test() {18val path = Paths.get("C:/test.txt")19path.parent shouldBe Paths.get("C:/")20}21import io.kotest.matchers.paths.parent22fun test() {23val path = Paths.get("C:/test.txt")24path.parent shouldBe Paths.get("C:/")25}26import io.kotest.matchers.paths.parent27fun test() {28val path = Paths.get("C:/test.txt")29path.parent shouldBe Paths.get("C:/")30}31import io.kotest.matchers.paths.parent32fun test() {33val path = Paths.get("C:/test.txt")34path.parent shouldBe Paths.get("C:/")35}36import io.kotest.matchers.paths.parent37fun test() {38val path = Paths.get("C:/test.txt")39path.parent shouldBe Paths.get("C:/")40}41import io.kotest.matchers.paths.parent42fun test() {43val path = Paths.get("C:/test.txt")44path.parent shouldBe Paths.get("C:/")45}46import io.kotest.matchers.paths.parent47fun test() {48val path = Paths.get("C:/test.txt")49path.parent shouldBe Paths.get("

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.paths.names.shouldMatchFilenameNames2class PathTest {3fun `should match filename names`() {4val path = Paths.get("/home/kotest/kotest.txt")5}6}7import io.kotest.matchers.paths.names.shouldNotMatchFilenameNames8class PathTest {9fun `should not match filename names`() {10val path = Paths.get("/home/kotest/kotest.txt")11}12}13import io.kotest.matchers.paths.names.shouldHaveFilenameNames14class PathTest {15fun `should have filename names`() {16val path = Paths.get("/home/kotest/kotest.txt")17path shouldHaveFilenameNames listOf("kotest.txt")18}19}20import io.kotest.matchers.paths.names.shouldNotHaveFilenameNames21class PathTest {22fun `should not have filename names`() {23val path = Paths.get("/home/kotest/kotest.txt")24path shouldNotHaveFilenameNames listOf("kotest")25}26}27import io.kotest.matchers.paths.names.shouldHaveFilenameNamesInOrder28class PathTest {29fun `should have filename names in order`() {30val path = Paths.get("/home/kotest/kotest.txt")31path shouldHaveFilenameNamesInOrder listOf("kotest.txt")32}33}34import io.kotest.matchers.paths.names.shouldHaveFilenameNamesExactly35class PathTest {36fun `should have filename names exactly`() {37val path = Paths.get("/home/kotest/kotest

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful