{"id":13608429,"url":"https://github.com/appmattus/kotlinfixture","last_synced_at":"2025-04-06T02:08:13.343Z","repository":{"id":36076375,"uuid":"208850028","full_name":"appmattus/kotlinfixture","owner":"appmattus","description":"Fixtures for Kotlin providing generated values for unit testing","archived":false,"fork":false,"pushed_at":"2024-08-20T06:49:58.000Z","size":1036,"stargazers_count":276,"open_issues_count":11,"forks_count":17,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-30T00:08:24.136Z","etag":null,"topics":["autofixture","fixture","hacktoberfest","kotlin","property-testing","test","testing","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appmattus.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":["mattmook"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-09-16T16:44:41.000Z","updated_at":"2025-03-14T18:55:38.000Z","dependencies_parsed_at":"2024-01-16T23:30:51.926Z","dependency_job_id":"527c992e-62d6-4013-8faa-770625fe3b1c","html_url":"https://github.com/appmattus/kotlinfixture","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appmattus%2Fkotlinfixture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appmattus%2Fkotlinfixture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appmattus%2Fkotlinfixture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appmattus%2Fkotlinfixture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appmattus","download_url":"https://codeload.github.com/appmattus/kotlinfixture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423514,"owners_count":20936626,"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":["autofixture","fixture","hacktoberfest","kotlin","property-testing","test","testing","testing-tools"],"created_at":"2024-08-01T19:01:27.160Z","updated_at":"2025-04-06T02:08:13.321Z","avatar_url":"https://github.com/appmattus.png","language":"Kotlin","funding_links":["https://github.com/sponsors/mattmook"],"categories":["Kotlin"],"sub_categories":[],"readme":"= KotlinFixture\nAppmattus Limited \u003cinfo@appmattus.com\u003e\n:toc: preamble\n:toc-title: Contents\n:homepage: https://github.com/appmattus/kotlinfixture\nifdef::env-github[]\n:tip-caption: :bulb:\n:note-caption: :information_source:\n:important-caption: :heavy_exclamation_mark:\n:caution-caption: :fire:\n:warning-caption: :warning:\nendif::[]\n:link-appmattus: https://github.com/appmattus/kotlinfixture[KotlinFixture]\n\nhttps://search.maven.org/search?q=g:com.appmattus.fixture[image:https://img.shields.io/maven-central/v/com.appmattus.fixture/fixture[Maven Central]]\nhttps://github.com/appmattus/kotlinfixture/actions[image:https://github.com/appmattus/kotlinfixture/workflows/CI/badge.svg[CI status]]\nhttps://codecov.io/gh/appmattus/kotlinfixture[image:https://codecov.io/gh/appmattus/kotlinfixture/branch/main/graph/badge.svg[Coverage status]]\nlink:LICENSE.md[image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License]]\n\nA tool to generate well-defined, but essentially random, input following the\nidea of constrained non-determinism.\n\n== Getting started\n\nInclude the following dependency in your `build.gradle.kts` file:\n\n[source,kotlin]\n._build.gradle.kts_\n----\ntestImplementation(\"com.appmattus.fixture:fixture:\u003clatest-version\u003e\")\n----\n\nSimply create a fixture and invoke it with the type to be generated:\n\n[source,kotlin]\n----\nval fixture = kotlinFixture()\n\n// Generate a list of strings\nval aListOfStrings = fixture\u003cList\u003cString\u003e\u003e()\n\n// Nulls are supported\nval sometimesNull = fixture\u003cInt?\u003e()\n\n// Create instances of classes\n// Optional parameters will be randomly used or overridden\ndata class ADataClass(val value: String = \"default\")\nval aClass = fixture\u003cADataClass\u003e()\n\n// Abstract classes will pick a sub-class at random\n// This could be a Byte, Double, Long, Float, Int or Short\nval anyNumber = fixture\u003cNumber\u003e()\n\n// Pick randomly from a list\nval randomStringFromTheList = fixture(listOf(\"Cat\", \"Dog\", \"Horse\"))\nval anotherRandomIntFromAList = fixture(1..5)\n----\n\nYou can also generate an infinite sequence of a type, which you can then\nfilter:\n\n[source,kotlin]\n----\nval fixture = kotlinFixture()\n\nval intSequence = fixture.asSequence\u003cInt\u003e()\n\n// Standard Kotlin sequence functions can then be applied before using\n// the sequence through an iterator for access to the next() function.\n\n// For example, you can filter values\nval oddIterator = intSequence.filter { it.absoluteValue.rem(2) == 1 }.iterator()\nval oddNumber = oddIterator.next()\nval anotherOddNumber = oddIterator.next()\n\n// Or, ensure it returns only distinct values\nenum class XYZ { X, Y, Z }\nval enumIterator = fixture.asSequence\u003cXYZ\u003e().distinct().iterator()\nval aDistinctValue = enumIterator.next()\nval anotherDistinctValue = enumIterator.next()\n----\n\n[WARNING]\n====\nThe sequence can hang indefinitely if the applied operators prevent the generation of new values. For example:\n\n* `distinct` will hang if we exhaust all available values. A good practice is to add a `take(count)` which will throw a `NoSuchElementException` if we try to generate more values.\n* `filter` that can never be fulfilled e.g. `filter { false }`\n====\n\n== Configuration options\n\nEverything can be customised, see link:fixture/configuration-options.adoc[configuration options] for more details.\n\nlink:fixture/advanced-customisation.adoc[Advanced engine customisation] is also possible if the above options are not enough.\n\n== Kotest integration: property based testing\n\nThe library provides {link-appmattus} powered property based testing for https://github.com/kotest/kotest/[Kotest].\n\nSee link:fixture-kotest/README.adoc[Kotest integration] for more details.\n\n== Java Faker integration: pretty data\n\nGenerate values with a closer match to real data using http://dius.github.io/java-faker/[Java Faker].\n\nSee link:fixture-javafaker/README.adoc[Java Faker integration] for more details.\n\n== Generex integration: regex to random string\n\nTo generate a random string from a regular expression, look no further than the Generex integration.\n\nSee link:fixture-generex/README.adoc[Generex integration] for more details.\n\n== Related projects\n\n* Marcello Galhardo's https://github.com/marcellogalhardo/kotlin-fixture[Kotlin.Fixture].\n* FlexTrade's https://github.com/FlexTradeUKLtd/kfixture[KFixture] wrapper for https://github.com/FlexTradeUKLtd/jfixture[JFixture].\n* Jeasy's https://github.com/j-easy/easy-random[Easy Random].\n\nPlease take a look at the feature link:fixture/comparison.adoc[comparison with related projects].\n\n== Contributing\n\nPlease fork this repository and contribute back using\nhttps://github.com/appmattus/kotlinfixture/pulls[pull requests].\n\nAll contributions, large or small, major features, bug fixes, additional\nlanguage translations, unit/integration tests are welcome.\n\n== License\n\nlink:LICENSE.md[image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License]]\n\nCopyright 2021 Appmattus Limited\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may\nnot use this file except in compliance with the License. You may obtain\na copy of the License at\nhttps://www.apache.org/licenses/LICENSE-2.0[https://www.apache.org/licenses/LICENSE-2.0].\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappmattus%2Fkotlinfixture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappmattus%2Fkotlinfixture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappmattus%2Fkotlinfixture/lists"}