How to use File.shouldExist method of io.kotest.matchers.file.matchers class

Best Kotest code snippet using io.kotest.matchers.file.matchers.File.shouldExist

AttachmentServiceTest.kt

Source:AttachmentServiceTest.kt Github

copy

Full Screen

1package com.github.njuro.jard.attachment2import com.github.njuro.jard.TEST_ATTACHMENT_AVI3import com.github.njuro.jard.TEST_ATTACHMENT_DOCX4import com.github.njuro.jard.TEST_ATTACHMENT_PNG5import com.github.njuro.jard.TEST_FOLDER_NAME6import com.github.njuro.jard.TestDataRepository7import com.github.njuro.jard.WithContainerDatabase8import com.github.njuro.jard.attachment9import com.github.njuro.jard.attachment.storage.RemoteStorageService10import com.github.njuro.jard.attachmentPath11import com.github.njuro.jard.common.Constants.DEFAULT_THUMBNAIL_EXTENSION12import com.github.njuro.jard.common.Constants.THUMBNAIL_FOLDER_NAME13import com.github.njuro.jard.embedData14import com.github.njuro.jard.metadata15import com.github.njuro.jard.multipartFile16import com.ninjasquad.springmockk.MockkBean17import io.kotest.matchers.booleans.shouldBeTrue18import io.kotest.matchers.file.shouldBeAFile19import io.kotest.matchers.file.shouldBeReadable20import io.kotest.matchers.file.shouldExist21import io.kotest.matchers.file.shouldHaveExtension22import io.kotest.matchers.file.shouldHaveNameWithoutExtension23import io.kotest.matchers.file.shouldNotBeEmpty24import io.kotest.matchers.file.shouldNotExist25import io.kotest.matchers.nulls.shouldBeNull26import io.kotest.matchers.nulls.shouldNotBeNull27import io.kotest.matchers.optional.shouldNotBePresent28import io.kotest.matchers.should29import io.kotest.matchers.shouldBe30import io.kotest.matchers.string.shouldNotBeBlank31import io.mockk.Runs32import io.mockk.every33import io.mockk.just34import org.junit.jupiter.api.AfterEach35import org.junit.jupiter.api.BeforeEach36import org.junit.jupiter.api.DisplayName37import org.junit.jupiter.api.Nested38import org.junit.jupiter.api.Test39import org.springframework.beans.factory.annotation.Autowired40import org.springframework.boot.test.context.SpringBootTest41import org.springframework.transaction.annotation.Transactional42import java.io.File43@SpringBootTest44@WithContainerDatabase45@Transactional46internal class AttachmentServiceTest {47 @Autowired48 private lateinit var attachmentService: AttachmentService49 @MockkBean50 private lateinit var remoteStorageService: RemoteStorageService51 @Autowired52 private lateinit var db: TestDataRepository53 @BeforeEach54 @AfterEach55 fun `delete test folder`() {56 val testFolder = attachmentPath(TEST_FOLDER_NAME).toFile()57 if (testFolder.exists()) {58 testFolder.deleteRecursively().shouldBeTrue()59 }60 }61 @Nested62 @DisplayName("save attachment")63 inner class SaveAttachment {64 private fun getRemoteUrl(folder: String, filename: String) = "https://remote-storage.com/$folder-$filename"65 @BeforeEach66 fun setUpMocks() {67 every {68 remoteStorageService.uploadFile(69 ofType(String::class),70 ofType(String::class),71 ofType(File::class)72 )73 } answers { getRemoteUrl(firstArg(), secondArg()) }74 }75 @Test76 fun `save image attachment with thumbnail`() {77 val file = multipartFile("attachment.png", TEST_ATTACHMENT_PNG)78 val attachment =79 attachment(80 category = AttachmentCategory.IMAGE,81 filename = file.name,82 folder = TEST_FOLDER_NAME,83 metadata = metadata(mimeType = "image/png")84 )85 attachmentService.saveAttachment(attachment, file).should {86 it.metadata.shouldNotBeNull()87 it.remoteStorageUrl shouldBe getRemoteUrl(attachment.folder, attachment.filename)88 it.file.shouldMatchFile("attachment", "png")89 it.remoteStorageThumbnailUrl shouldBe getRemoteUrl(90 "$TEST_FOLDER_NAME/$THUMBNAIL_FOLDER_NAME",91 attachment.filename92 )93 it.thumbnailFile.shouldMatchFile("attachment", "png")94 }95 }96 @Test97 fun `save non-image attachment with thumbnail`() {98 val file = multipartFile("attachment.avi", TEST_ATTACHMENT_AVI)99 val attachment =100 attachment(101 category = AttachmentCategory.VIDEO,102 filename = file.name,103 folder = TEST_FOLDER_NAME,104 metadata = metadata(mimeType = "video/avi")105 )106 attachmentService.saveAttachment(attachment, file).should {107 it.remoteStorageUrl.shouldNotBeBlank()108 it.file.shouldMatchFile("attachment", "avi")109 it.thumbnailFile.shouldMatchFile("attachment", DEFAULT_THUMBNAIL_EXTENSION)110 it.remoteStorageThumbnailUrl.shouldNotBeBlank()111 }112 }113 @Test114 fun `save non-image attachment without thumbnail`() {115 val file = multipartFile("attachment.docx", TEST_ATTACHMENT_DOCX)116 val attachment =117 attachment(118 category = AttachmentCategory.TEXT,119 filename = file.name,120 folder = TEST_FOLDER_NAME,121 metadata = metadata(mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document")122 )123 attachmentService.saveAttachment(attachment, file).should {124 it.file.shouldMatchFile("attachment", "docx")125 it.remoteStorageUrl.shouldNotBeBlank()126 it.thumbnailFile.shouldBeNull()127 it.remoteStorageThumbnailUrl.shouldBeNull()128 }129 }130 @Test131 fun `save embedded attachment`() {132 val attachment =133 attachment(category = AttachmentCategory.EMBED, embedData = embedData(embedUrl = "some-url"))134 attachmentService.saveEmbeddedAttachment(attachment).shouldNotBeNull()135 }136 }137 @Test138 fun `delete attachment`() {139 every { remoteStorageService.uploadFile(any(), any(), any()) } returns null140 every { remoteStorageService.deleteFile(ofType(String::class), ofType(String::class)) } just Runs141 val file = multipartFile("attachment.png", TEST_ATTACHMENT_PNG)142 val attachment =143 attachment(144 category = AttachmentCategory.IMAGE,145 filename = file.name,146 folder = TEST_FOLDER_NAME,147 metadata = metadata(mimeType = "image/png")148 )149 val saved = attachmentService.saveAttachment(attachment, file)150 attachmentService.deleteAttachment(saved)151 db.select(saved).shouldNotBePresent()152 attachment.file.shouldNotExist()153 attachment.thumbnailFile.shouldNotExist()154 }155 private fun File.shouldMatchFile(name: String, extension: String) = should {156 it.shouldExist()157 it.shouldBeAFile()158 it.shouldHaveNameWithoutExtension(name)159 it.shouldHaveExtension(extension)160 it.shouldBeReadable()161 it.shouldNotBeEmpty()162 }163}...

Full Screen

Full Screen

ConsumerRulesFilterTest.kt

Source:ConsumerRulesFilterTest.kt Github

copy

Full Screen

1/*2 * ProGuard -- shrinking, optimization, obfuscation, and preverification3 * of Java bytecode.4 *5 * Copyright (c) 2002-2022 Guardsquare NV6 */7package proguard.gradle8import io.kotest.core.spec.style.FreeSpec9import io.kotest.matchers.file.shouldExist10import io.kotest.matchers.shouldBe11import io.kotest.matchers.string.shouldContain12import io.kotest.matchers.string.shouldNotContain13import java.io.File14import org.gradle.testkit.runner.TaskOutcome15import testutils.AndroidProject16import testutils.applicationModule17import testutils.createGradleRunner18import testutils.createTestKitDir19class ConsumerRulesFilterTest : FreeSpec({20 val testKitDir = createTestKitDir()21 "Given a project with a configuration block for a specific variant" - {22 val project = autoClose(AndroidProject().apply {23 addModule(24 applicationModule(25 "app", buildDotGradle = """26 plugins {27 id 'com.android.application'28 id 'com.guardsquare.proguard'29 }30 android {31 compileSdkVersion 3032 buildTypes {33 release {34 minifyEnabled false35 }36 }37 }38 proguard {39 configurations {40 release {41 consumerRuleFilter 'filter1', 'filter2'42 }43 }44 }""".trimIndent()))45 }.create())46 "When the project is evaluated" - {47 val result = createGradleRunner(project.rootDir, testKitDir, "-si").build()48 "Then the build should succeed" {49 result.output shouldContain "BUILD SUCCESSFUL"50 }51 }52 }53 "Given an application project with a consumer rule filter" - {54 val project = autoClose(AndroidProject().apply {55 addModule(56 applicationModule(57 "app", buildDotGradle = """58 plugins {59 id 'com.android.application'60 id 'com.guardsquare.proguard'61 }62 63 repositories {64 google()65 mavenCentral()66 }67 68 dependencies {69 implementation 'com.android.support:appcompat-v7:28.0.0'70 }71 72 android {73 compileSdkVersion 2974 defaultConfig {75 targetSdkVersion 3076 minSdkVersion 1477 versionCode 178 }79 buildTypes {80 release {}81 debug {}82 }83 }84 85 proguard {86 configurations {87 release {88 defaultConfiguration 'proguard-android.txt'89 consumerRuleFilter 'com.android.support:appcompat-v7'90 }91 }92 } """.trimIndent()))93 }.create())94 "When the 'clean' and 'assemble' tasks are run" - {95 val result = createGradleRunner(project.rootDir, testKitDir, "clean", "assemble").build()96 "Then the tasks should run successfully" {97 result.task(":app:assemble")?.outcome shouldBe TaskOutcome.SUCCESS98 result.task(":app:assembleRelease")?.outcome shouldBe TaskOutcome.SUCCESS99 result.task(":app:assembleDebug")?.outcome shouldBe TaskOutcome.SUCCESS100 }101 "Then the release and debug apks are built" {102 File(project.rootDir, "app/build/outputs/apk/release/app-release-unsigned.apk").shouldExist()103 File(project.rootDir, "app/build/outputs/apk/debug/app-debug.apk").shouldExist()104 }105 "Then the excluded consumer rules are not in 'consumer-rules.pro'" {106 val consumerRuleFile =107 File(project.rootDir, "app/build/intermediates/proguard/configs/release/consumer-rules.pro")108 consumerRuleFile.shouldExist()109 consumerRuleFile.readText() shouldNotContain "com.android.support:appcompat-v7:28.0.0"110 }111 }112 "When the 'clean' and 'bundle' tasks are run" - {113 val result = createGradleRunner(project.rootDir, testKitDir, "clean", "bundle").build()114 "Then the tasks should run successfully" {115 result.task(":app:bundle")?.outcome shouldBe TaskOutcome.SUCCESS116 result.task(":app:bundleRelease")?.outcome shouldBe TaskOutcome.SUCCESS117 result.task(":app:bundleDebug")?.outcome shouldBe TaskOutcome.SUCCESS118 }119 "Then the release and debug aabs are built" {120 File(project.rootDir, "app/build/outputs/bundle/release/app-release.aab").shouldExist()121 File(project.rootDir, "app/build/outputs/bundle/debug/app-debug.aab").shouldExist()122 }123 "Then the excluded consumer rules are not in 'consumer-rules.pro'" {124 val consumerRuleFile =125 File(project.rootDir, "app/build/intermediates/proguard/configs/release/consumer-rules.pro")126 consumerRuleFile.shouldExist()127 consumerRuleFile.readText() shouldNotContain "com.android.support:appcompat-v7:28.0.0"128 }129 }130 }131})...

Full Screen

Full Screen

ConsumerRulesCollectionTest.kt

Source:ConsumerRulesCollectionTest.kt Github

copy

Full Screen

1package proguard.gradle2/*3 * ProGuard -- shrinking, optimization, obfuscation, and preverification4 * of Java bytecode.5 *6 * Copyright (c) 2002-2020 Guardsquare NV7 */8import io.kotest.core.spec.style.FreeSpec9import io.kotest.matchers.file.shouldExist10import io.kotest.matchers.file.shouldNotExist11import io.kotest.matchers.shouldBe12import io.kotest.matchers.string.shouldContain13import io.kotest.matchers.string.shouldNotContain14import java.io.File15import org.gradle.testkit.runner.TaskOutcome16import testutils.AndroidProject17import testutils.applicationModule18import testutils.createGradleRunner19import testutils.createTestKitDir20class ConsumerRulesCollectionTest : FreeSpec({21 val testKitDir = createTestKitDir()22 "Given an Android project with one configured variant" - {23 val project = autoClose(AndroidProject().apply {24 addModule(applicationModule("app", buildDotGradle = """25 plugins {26 id 'com.android.application'27 id 'com.guardsquare.proguard'28 }29 android {30 compileSdkVersion 3031 buildTypes {32 release {33 minifyEnabled false34 }35 debug {36 minifyEnabled false37 }38 }39 }40 proguard {41 configurations {42 release {}43 }44 }45 """.trimIndent()))46 }.create())47 "When the tasks 'clean' and 'assembleDebug' are executed in a dry run" - {48 val result = createGradleRunner(project.rootDir, testKitDir, "--dry-run", "clean", "assembleDebug").build()49 "Then the 'collectConsumerRulesDebug' task would not be executed" {50 result.output.shouldNotContain("collectConsumerRulesDebug")51 }52 }53 "When the tasks 'clean' and 'assembleRelease' are executed in a dry run" - {54 val result = createGradleRunner(project.rootDir, testKitDir, "--dry-run", "clean", "assembleRelease").build()55 "Then the 'collectConsumerRulesRelease' task would be executed" {56 result.output.shouldContain("collectConsumerRulesRelease")57 }58 }59 "When the tasks 'clean' and 'collectConsumerRulesDebug' are executed " - {60 val result = createGradleRunner(project.rootDir, testKitDir, "clean", "collectConsumerRulesDebug").buildAndFail()61 "Then the task 'collectConsumerRulesDebug' is not executed" {62 result.task(":app:collectConsumerRulesDebug")?.outcome shouldBe null63 }64 "Then a subdirectory of the build directory should not contain the consumer rules" {65 File("${project.rootDir}/app/build/intermediates/proguard/configs/debug/consumer-rules.pro").shouldNotExist()66 }67 }68 "When the tasks 'clean' and 'collectConsumerRulesRelease' are executed " - {69 val result = createGradleRunner(project.rootDir, testKitDir, "clean", "collectConsumerRulesRelease").build()70 "Then the task 'collectConsumerRulesRelease' is successful" {71 result.task(":app:collectConsumerRulesRelease")?.outcome shouldBe TaskOutcome.SUCCESS72 }73 "Then a subdirectory of the build directory should contain the consumer rules" {74 File("${project.rootDir}/app/build/intermediates/proguard/configs/release/consumer-rules.pro").shouldExist()75 }76 }77 }78})...

Full Screen

Full Screen

PublishToMavenCentralTest.kt

Source:PublishToMavenCentralTest.kt Github

copy

Full Screen

1package it.nicolasfarabegoli.gradle.central2import io.kotest.core.spec.style.WordSpec3import io.kotest.matchers.file.shouldBeAFile4import io.kotest.matchers.file.shouldExist5import io.kotest.matchers.shouldBe6import io.kotest.matchers.string.shouldContain7import org.gradle.testkit.runner.GradleRunner8import org.gradle.testkit.runner.TaskOutcome9import java.io.File10class PublishToMavenCentralTest : WordSpec({11 val projectDir = File("build/gradleTest")12 fun setupTest() {13 projectDir.mkdirs()14 projectDir.resolve("settings.gradle.kts").writeText("")15 projectDir.resolve("build.gradle.kts").writeText(16 """17 plugins {18 `java-library`19 `java-gradle-plugin`20 id("it.nicolasfarabegoli.publish-to-maven-central")21 }22 23 publishOnMavenCentral {24 projectDescription.set("foo bar")25 repository("https://maven.pkg.github.com/foo/bar", "github") {26 username.set("foo")27 password.set("bar")28 }29 }30 """.trimIndent()31 )32 }33 val taskName = "generatePomFileForJavaMavenPublication"34 "The plugin" should {35 "create the correct tasks" {36 setupTest()37 val tasks = GradleRunner.create()38 .forwardOutput()39 .withPluginClasspath()40 .withProjectDir(projectDir)41 .withArguments("tasks")42 .build()43 tasks.output shouldContain "publishJavaMavenPublication"44 tasks.output shouldContain "publishPluginMavenPublicationToMavenCentralRepository"45 tasks.output shouldContain "publishJavaMavenPublicationToGithubRepository"46 tasks.output shouldContain "releaseJavaMavenOnMavenCentralNexus"47 tasks.output shouldContain "publishPluginMavenPublicationToGithubRepository"48 tasks.output shouldContain "releasePlugin"49 }50 "generate the pom correctly" {51 setupTest()52 val result = GradleRunner.create()53 .forwardOutput()54 .withPluginClasspath()55 .withArguments(taskName, "sourcesJar", "javadocJar", "--stacktrace")56 .withProjectDir(projectDir)57 .build()58 result.task(":$taskName")?.outcome shouldBe TaskOutcome.SUCCESS59 with(File("$projectDir/build/publications/javaMaven/pom-default.xml")) {60 shouldExist()61 shouldBeAFile()62 val content = readText(Charsets.UTF_8)63 content shouldContain "artifactId"64 content shouldContain "groupId"65 content shouldContain "name"66 content shouldContain "url"67 content shouldContain "license"68 }69 }70 }71})...

Full Screen

Full Screen

WebappTest.kt

Source:WebappTest.kt Github

copy

Full Screen

1package family.haschka.wolkenschloss.conventions2import io.kotest.assertions.assertSoftly3import io.kotest.core.spec.style.DescribeSpec4import io.kotest.matchers.collections.shouldContainAll5import io.kotest.matchers.file.shouldBeADirectory6import io.kotest.matchers.file.shouldContainFile7import io.kotest.matchers.file.shouldExist8import io.kotest.matchers.shouldBe9import org.gradle.testkit.runner.TaskOutcome10import family.haschka.wolkenschloss.testing.Template11import family.haschka.wolkenschloss.testing.build12class WebappTest : DescribeSpec({13 describe("project with vue application") {14 val fixture = autoClose(Template("webapp"))15 describe("build task") {16 it("should create jar file") {17 fixture.withClone {18 val result = build("build")19 result.task(":build")!!.outcome shouldBe TaskOutcome.SUCCESS20 result.task(":vue")!!.outcome shouldBe TaskOutcome.SUCCESS21 workingDirectory.resolve("build/libs/fixture-webapp.jar").shouldExist()22 }23 }24 }25 describe("check task") {26 it("should run unit and e2e tasks") {27 fixture.withClone {28 val result = build("check")29 result.tasks(TaskOutcome.SUCCESS)30 .map { task -> task.path }31 .shouldContainAll(":unit", ":e2e", ":check")32 }33 }34 }35 describe("vue task") {36 it("should build vue app") {37 fixture.withClone {38 val result = build("vue")39 result.task(":vue")!!.outcome shouldBe TaskOutcome.SUCCESS40 assertSoftly(workingDirectory.resolve("build/classes/java/main/META-INF/resources")) {41 shouldBeADirectory()42 shouldContainFile("index.html")43 resolve("js").shouldBeADirectory()44 }45 }46 }47 }48 describe("unit task") {49 it("should run unit tests") {50 fixture.withClone {51 val result = build("unit")52 result.task(":unit")!!.outcome shouldBe TaskOutcome.SUCCESS53 workingDirectory.resolve("build/reports/tests/unit").shouldContainFile("junit.xml")54 }55 }56 }57 describe("e2e task") {58 it("should run e2e tests") {59 fixture.withClone {60 val result = build("e2e")61 result.task(":e2e")!!.outcome shouldBe TaskOutcome.SUCCESS62 workingDirectory.resolve("build/reports/tests/e2e").shouldBeADirectory()63 }64 }65 }66 }67})...

Full Screen

Full Screen

TestEffectLoading.kt

Source:TestEffectLoading.kt Github

copy

Full Screen

1/*2 * Copyright (C) 2010-2022, Danilo Pianini and contributors3 * listed, for each module, in the respective subproject's build.gradle.kts file.4 *5 * This file is part of Alchemist, and is distributed under the terms of the6 * GNU General Public License, with a linking exception,7 * as described in the file LICENSE in the Alchemist distribution's top directory.8 */9@file:Suppress("DEPRECATION")10package it.unibo.alchemist.test11import io.kotest.core.spec.style.StringSpec12import io.kotest.engine.spec.tempfile13import io.kotest.matchers.file.shouldBeAFile14import io.kotest.matchers.file.shouldExist15import io.kotest.matchers.file.shouldNotBeEmpty16import io.kotest.matchers.nulls.beNull17import io.kotest.matchers.nulls.shouldNotBeNull18import io.kotest.matchers.shouldBe19import io.kotest.matchers.shouldNot20import it.unibo.alchemist.boundary.gui.effects.DrawBidimensionalGaussianLayersGradient21import it.unibo.alchemist.boundary.gui.effects.EffectSerializationFactory22import org.kaikikm.threadresloader.ResourceLoader23import java.io.File24class TestEffectLoading : StringSpec(25 {26 "effects with layers should be (de)serializable" {27 val target = DrawBidimensionalGaussianLayersGradient()28 val tempFile = tempfile()29 EffectSerializationFactory.effectToFile(tempFile, target)30 println(tempFile.readText())31 tempFile.shouldExist()32 tempFile.shouldBeAFile()33 tempFile.shouldNotBeEmpty()34 EffectSerializationFactory.effectsFromFile(tempFile).shouldNotBeNull()35 }36 "legacy effects with layers should be deserializable" {37 val target = ResourceLoader.getResource("layer.json")38 target shouldNot beNull()39 val file = File(target.file)40 file.shouldExist()41 file.shouldNotBeEmpty()42 file.shouldBeAFile()43 val effects = EffectSerializationFactory.effectsFromFile(file)44 effects.shouldNotBeNull()45 effects.size shouldBe 446 }47 }48)...

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

FileWriterTest.kt

Source:FileWriterTest.kt Github

copy

Full Screen

1package br.com.colman.petals.use.io2import androidx.test.platform.app.InstrumentationRegistry3import io.kotest.matchers.file.shouldExist4import io.kotest.matchers.file.shouldNotExist5import io.kotest.matchers.shouldBe6import io.kotest.matchers.string.shouldEndWith7import org.junit.Before8import org.junit.Test9import java.io.File10class FileWriterTest {11 val context = InstrumentationRegistry.getInstrumentation().targetContext12 val exportsDirectory = File(context.filesDir, "exports")13 val target = FileWriter(context)14 @Before15 fun deleteExportsDirectory() {16 exportsDirectory.deleteRecursively()17 }18 @Test19 fun createsExportsDirectory() {20 exportsDirectory.shouldNotExist()21 target.write("abc")22 exportsDirectory.shouldExist()23 }24 @Test25 fun replacesExistingFile() {26 val uri1 = target.write("abc")27 val uri2 = target.write("def")28 uri1 shouldBe uri229 val content = context.contentResolver.openInputStream(uri2)!!30 content.bufferedReader().readText() shouldBe "def"31 }32 @Test33 fun defaultFIleName() {34 val uri = target.write("xxx")35 uri.path shouldEndWith "PetalsExport.csv"36 }37}...

Full Screen

Full Screen

File.shouldExist

Using AI Code Generation

copy

Full Screen

1File(“/path/to/file”).shouldExist()2File(“/path/to/file”).shouldNotExist()3File(“/path/to/file”).shouldHaveExtension(“txt”)4File(“/path/to/file”).shouldHaveName(“file.txt”)5File(“/path/to/file”).shouldHaveParent(“/path/to”)6File(“/path/to/file”).shouldHaveParentDirectory(File(“/path/to”))7File(“/path/to/file”).shouldHavePath(“/path/to/file”)8File(“/path/to/file1”).shouldHaveSameContentAs(File(“/path/to/file2”))9File(“/path/to/file”).shouldHaveSameContentAs(“file content”)10File(“/path/to/file”).shouldHaveSize(100)11File(“/path/to/file”).shouldHaveText(“file content”)12File(“/path/to/file”).shouldHaveText(“file content”, Charsets.UTF_8)13File(“/path/to/file”).shouldHaveText(“file content”, Charsets.UTF_8, LineSeparator.UNIX)

Full Screen

Full Screen

File.shouldExist

Using AI Code Generation

copy

Full Screen

1File("src/test/resources/file.txt").shouldExist()2File("src/test/resources/file.txt").shouldBeEmpty()3File("src/test/resources/file.txt").shouldBeHidden()4File("src/test/resources/file.txt").shouldBeReadable()5File("src/test/resources/file.txt").shouldBeWritable()6File("src/test/resources/file.txt").shouldBeRelative()7File("src/test/resources/file.txt").shouldBeAbsolute()8File("src/test/resources/file.txt").shouldBeSymlink()9File("src/test/resources/file.txt").shouldBeDirectory()10File("src/test/resources/file.txt").shouldBeFile()11File("src/test/resources/file.txt").shouldHaveExtension("txt")12File("src/test/resources/file.txt").shouldHaveParent("src/test/resources")13File("src/test/resources/file.txt").shouldHaveName("file.txt")14File("src/test/resources/file.txt").shouldHaveNameStartingWith("file")15File("src/test/resources/file.txt").shouldHaveNameEndingWith("txt")

Full Screen

Full Screen

File.shouldExist

Using AI Code Generation

copy

Full Screen

1File("my-file.txt").shouldExist()2File("my-file.txt").shouldBeEmpty()3File("my-file.txt").shouldBeReadable()4File("my-file.txt").shouldBeWritable()5File("my-file.txt").shouldBeExecutable()6File("my-file.txt").shouldBeSymbolicLink()7File("my-file.txt").shouldBeRelative()8File("my-file.txt").shouldBeAbsolute()9File("my-file.txt").shouldBeHidden()10File("my-file.txt").shouldHaveExtension("txt")11File("my-file.txt").shouldHaveName("my-file.txt")12File("my-file.txt").shouldHaveParent("my-folder")13File("my-file.txt").shouldHaveParent(File("my-folder"))14File("my-file.txt").shouldHaveNameStartingWith("my")15File("my-file.txt").shouldHaveNameEndingWith("txt")16File("my-file.txt").shouldHaveNameContaining("file

Full Screen

Full Screen

File.shouldExist

Using AI Code Generation

copy

Full Screen

1 import io.kotest.matchers.file.matchers.shouldExist2 import java.io.File3 import java.nio.file.Paths4 fun main() {5 val file = File.createTempFile("test", ".txt")6 file.shouldExist()7 }8 import io.kotest.matchers.file.matchers.shouldNotExist9 import java.io.File10 import java.nio.file.Paths11 fun main() {12 val file = File.createTempFile("test", ".txt")13 file.delete()14 file.shouldNotExist()15 }16 import io.kotest.matchers.file.matchers.shouldBeEmpty17 import java.io.File18 import java.nio.file.Paths19 fun main() {20 val file = File.createTempFile("test", ".txt")21 file.shouldBeEmpty()22 }23 import io.kotest.matchers.file.matchers.shouldNotBeEmpty24 import java.io.File25 import java.nio.file.Paths26 fun main() {27 val file = File.createTempFile("test", ".txt")

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful