{"id":16550303,"url":"https://github.com/sylhare/randomk","last_synced_at":"2025-03-04T15:27:24.605Z","repository":{"id":45315726,"uuid":"393133724","full_name":"sylhare/RandomK","owner":"sylhare","description":"Use randomK in your tests to create real objects with fake data automatically.","archived":false,"fork":false,"pushed_at":"2021-12-21T19:39:26.000Z","size":185,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-14T20:22:10.239Z","etag":null,"topics":["kotlin","kotlin-library","test","testing-library","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sylhare.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}},"created_at":"2021-08-05T18:09:31.000Z","updated_at":"2024-01-19T15:38:34.000Z","dependencies_parsed_at":"2022-09-01T22:21:44.410Z","dependency_job_id":null,"html_url":"https://github.com/sylhare/RandomK","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylhare%2FRandomK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylhare%2FRandomK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylhare%2FRandomK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylhare%2FRandomK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sylhare","download_url":"https://codeload.github.com/sylhare/RandomK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241870999,"owners_count":20034381,"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":["kotlin","kotlin-library","test","testing-library","testing-tools"],"created_at":"2024-10-11T19:33:48.103Z","updated_at":"2025-03-04T15:27:24.586Z","avatar_url":"https://github.com/sylhare.png","language":"Kotlin","readme":"# RandomK\n\nCreate random instance from a class. It\nuses [`kotlin-reflect`](https://kotlinlang.org/docs/reflection.html#class-references)\nto create by reflection the instance. (Using [KClass](https://kotlinlang.org/docs/reflection.html#class-references)\nand [KType](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-type/))\n\n\u003e _Reflection_ is a set of language and library features that allows for introspecting the structure of your own program at runtime.\n\nBased on [Marcin Moskala](https://github.com/MarcinMoskala) from [Kt Academy](https://kt.academy/) 's article:\n\n- [Creating a random instance of any class in Kotlin](https://blog.kotlin-academy.com/creating-a-random-instance-of-any-class-in-kotlin-b6168655b64a)\n\n## How to use\n\n### Add the dependency\n\n#### Create a GitHub Personal Access Token\n\nTo use the packages hosted on the GPR (GitHub Package Registry) you need your username/token. Add the GPR as a\nrepository inside your [build.gradle.kts](Example/build.gradle.kts):\n\n```kotlin\nmaven {\n    url = uri(\"https://maven.pkg.github.com/sylhare/RandomK\")\n    credentials {\n        username = project.findProperty(\"gpr.user\") as String? ?: System.getenv(\"USERNAME\")\n        password = project.findProperty(\"gpr.key\") as String? ?: System.getenv(\"TOKEN\")\n    }\n}\n```\n\nYou can set those variables using:\n\n```bash\nexport USERNAME=\"my-github-username\"\nexport TOKEN=\"my-secret-personal-access-token-for-github\"\n```\n\nThen add the randomK dependency:\n\n```kotlin\ndependencies {\n    implementation(\"com.github.sylhare:randomk:$randomKVersion\")\n}\n```\n\nWith the latest version available, check out the [_package_](https://github.com/sylhare/RandomK/packages/978387) section\n😉\n\nFind the full example [here](Example).\n\n### In your code\n\nSince we're using `typeOf\u003cT\u003e()` fom kotlin-reflect to detect the retention type (introduced in kotlin v1.3), the library\nis under the `@ExperimentalStdlibApi`.\n\nYou can create a random instance with `randomK` like:\n\n```kotlin\nprivate val example: Example = randomK()\nprivate val otherExample = randomK\u003cOtherExample\u003e()\n```\n\nIt will create a random instance.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsylhare%2Frandomk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsylhare%2Frandomk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsylhare%2Frandomk/lists"}