{"id":21183460,"url":"https://github.com/jgleitz/testfiles","last_synced_at":"2025-07-10T00:33:06.040Z","repository":{"id":36991099,"uuid":"291475007","full_name":"jGleitz/testfiles","owner":"jGleitz","description":"Manage test files and directories neatly when testing with Spek or Kotest!","archived":false,"fork":false,"pushed_at":"2024-11-11T17:12:26.000Z","size":2292,"stargazers_count":7,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-11T18:23:19.474Z","etag":null,"topics":["kotest","kotest-plugin","kotlin","spek2","spekframework","testing"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jGleitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-30T13:25:01.000Z","updated_at":"2023-06-14T08:44:12.000Z","dependencies_parsed_at":"2023-12-21T20:20:31.720Z","dependency_job_id":"804961f5-95aa-4fb0-8a15-03875f8ab56b","html_url":"https://github.com/jGleitz/testfiles","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jGleitz%2Ftestfiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jGleitz%2Ftestfiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jGleitz%2Ftestfiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jGleitz%2Ftestfiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jGleitz","download_url":"https://codeload.github.com/jGleitz/testfiles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225606602,"owners_count":17495551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotest","kotest-plugin","kotlin","spek2","spekframework","testing"],"created_at":"2024-11-20T18:00:28.578Z","updated_at":"2024-11-20T18:01:27.102Z","avatar_url":"https://github.com/jGleitz.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# testfiles [![CI Status](https://github.com/jGleitz/spek-testfiles/workflows/CI/badge.svg)](https://github.com/jGleitz/spek-testfiles/actions)\n\nA test helper to easily create files and directories for testing purposes.\n\n* Organises test files according to the test structure\n* Cleans up test files, but leaves them in place if the test fails, so you can examine them\n* Generates random file names that are consistent each test run\n* Supports [Spek](https://www.spekframework.org/) and [Kotest](https://kotest.io/)\n\n## Dependencies\n\nFramework | Link | Dependency\n--- | --- | ---\n[Spek](https://www.spekframework.org/) |  [![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.joshuagleitze/spek-testfiles/badge.svg)](https://maven-badges.herokuapp.com/maven-central/de.joshuagleitze/spek-testfiles) | `de.joshuagleitze:spek-testfiles:\u003cversion\u003e`\n[Kotest](https://kotest.io/) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.joshuagleitze/kotest-files/badge.svg)](https://maven-badges.herokuapp.com/maven-central/de.joshuagleitze/kotest-files) | `de.joshuagleitze:kotest-files:\u003cversion\u003e`\n\n## Usage\n\n### Spek\n\nCreate a `testFiles` instance for your Spek by using\nthe  [`testFiles()`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles.spek/test-files.html) function:\n\n```kotlin\nimport de.joshuagleitze.testfiles.DeletionMode.*\nimport de.joshuagleitze.testfiles.spek.testFiles\nimport org.spekframework.spek2.Spek\nimport org.spekframework.spek2.style.specification.describe\n\nobject ExampleSpek: Spek({\n\tval testFiles = testFiles()\n\n\tdescribe(\"using test files\") {\n\t\tit(\"generates file names\") {\n\t\t\ttestFiles.createFile()\n\t\t\ttestFiles.createDirectory()\n\t\t}\n\n\t\tit(\"cleans up files\") {\n\t\t\ttestFiles.createFile(\"irrelevant\", delete = Always)\n\t\t\ttestFiles.createFile(\"default mode\", delete = IfSuccessful)\n\t\t\ttestFiles.createFile(\"output\", delete = Never)\n\t\t}\n\t}\n})\n\n```\n\n### Kotest\n\nUse the global [`testFiles`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles.kotest/test-files.html) property:\n\n```kotlin\nimport de.joshuagleitze.testfiles.DeletionMode.*\nimport de.joshuagleitze.testfiles.kotest.testFiles\nimport io.kotest.core.spec.style.DescribeSpec\n\nclass ExampleSpek: DescribeSpec({\n\tdescribe(\"using test files\") {\n\t\tit(\"generates file names\") {\n\t\t\ttestFiles.createFile()\n\t\t\ttestFiles.createDirectory()\n\t\t}\n\n\t\tit(\"cleans up files\") {\n\t\t\ttestFiles.createFile(\"irrelevant\", delete = Always)\n\t\t\ttestFiles.createFile(\"default mode\", delete = IfSuccessful)\n\t\t\ttestFiles.createFile(\"output\", delete = Never)\n\t\t}\n\t}\n})\n```\n\n## Test File Directory\n\n`testfiles` will automatically pick the most appropriate folder to create the files in. Concretely, it uses this logic (\nsee [DefaultTestFiles.determineTestFilesRootDirectory](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles/-default-test-files/-companion/determine-test-files-root-directory.html)):\n\nCase | Test File Directory | Use Case\n--- | --- | ---\n`\u003cpwd\u003e/build` exists | `\u003cpwd\u003e/build/test-outputs` | Gradle users\n`\u003cpwd\u003e/target` exists | `\u003cpwd\u003e/target/test-outputs` | Maven users\n`\u003cpwd\u003e/test-outputs` exists | `\u003cpwd\u003e/test-outputs` | Other users wishing to have the files in the project directory\nelse | `\u003ctmpdir\u003e/spek-test-outputs` | Fallback \n\nThe files in the test directory will be organized into directories according to the test structure.\nFor example, the “output” file from the example above would be created at `\u003ctest file directory\u003e/[ExampleSpek]/[using test files]/[cleans up files]/output`. \n\n## Deletion Mode\n\nPer default, `testiles` will delete created files and directories if the current test or group was successful and retain them if the test or\ngroup failed. This allows you to examine test output after tests fails, but does not clutter your test output folder.\n\nThe behaviour can be changed by passing the\ncorrect [`DeletionMode`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles/-deletion-mode/index.html)\nto [`createFile`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles/-test-files/create-file.html)\nor [`createDirectory`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles/-test-files/create-directory.html):\n\n[`DeletionMode`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles/-deletion-mode/index.html) | behaviour\n--- | ---\n[`Always`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles/-deletion-mode/-always/index.html) | Always delete the created file after the test or group has run.\n[`IfSuccessful`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles/-deletion-mode/-if-successful/index.html) | Delete the file if the test or group ran through successfully; retain the file if the test or group failed. The default value.\n[`Never`](https://jgleitz.github.io/testfiles/testfiles/de.joshuagleitze.testfiles/-deletion-mode/-never/index.html) | always retain the file after the test run.\n\nRetained files will be deleted once the group or test they were created for is executed again.\n\n## File Names\n\nIf no file or directory name is provided, `testfiles` will create one. Names are constructed following the pattern `test-\u003cnumber\u003e`\nwhere `\u003cnumber\u003e` is a randomly generated, non-negative integer. The random generator is seeded with the current test directory path to make\nsure the same test will always get the same file names every execution.\n\nFor example, the first generated file from the example above might have the\npath `\u003ctest file directory\u003e/[ExampleSpek]/[using test files]/[generates file names]/test-162363182`.\n\nIf a file name is provided, the name must not be wrapped in angle brackets.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgleitz%2Ftestfiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgleitz%2Ftestfiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgleitz%2Ftestfiles/lists"}