{"id":18559070,"url":"https://github.com/linux-china/easy-random-junit5-extension","last_synced_at":"2025-10-27T23:32:03.140Z","repository":{"id":47457553,"uuid":"403174843","full_name":"linux-china/easy-random-junit5-extension","owner":"linux-china","description":"JUnit 5 extension for easy-random","archived":false,"fork":false,"pushed_at":"2023-01-28T07:45:18.000Z","size":103,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-17T00:03:52.881Z","etag":null,"topics":["easy-random","junit-extension","junit5"],"latest_commit_sha":null,"homepage":"","language":"Java","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/linux-china.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-09-04T23:27:20.000Z","updated_at":"2023-08-10T06:07:08.000Z","dependencies_parsed_at":"2023-02-15T14:55:35.669Z","dependency_job_id":null,"html_url":"https://github.com/linux-china/easy-random-junit5-extension","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/linux-china/easy-random-junit5-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Feasy-random-junit5-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Feasy-random-junit5-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Feasy-random-junit5-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Feasy-random-junit5-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linux-china","download_url":"https://codeload.github.com/linux-china/easy-random-junit5-extension/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Feasy-random-junit5-extension/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281361406,"owners_count":26487881,"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","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["easy-random","junit-extension","junit5"],"created_at":"2024-11-06T21:41:58.518Z","updated_at":"2025-10-27T23:32:03.082Z","avatar_url":"https://github.com/linux-china.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cb\u003e\u003cem\u003eEasy Random/Faker JUnit 5 extension\u003c/em\u003e\u003c/b\u003e\u003cbr\u003e\n    The simple, stupid random Java\u0026trade; beans generator for JUnit 5\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![MIT license](https://img.shields.io/badge/license-Apache-brightgreen.svg?style=flat)](http://opensource.org/licenses/Apache-2.0)\n[![Build Status](https://github.com/linux-china/easy-random-junit5-extension/actions/workflows/main.yml/badge.svg)](https://github.com/linux-china/easy-random-junit5-extension/actions)\n[![Maven Central](https://img.shields.io/maven-central/v/org.mvnsearch/easy-random-junit5-extension)](https://repo1.maven.org/maven2/org/mvnsearch/easy-random-junit5-extension/)\n[![Project status](https://img.shields.io/badge/Project%20status-Maintenance-orange.svg)](https://img.shields.io/badge/Project%20status-Maintenance-orange.svg)\n\n\u003c/div\u003e\n\nThe easy random extension provides a test with randomly generated objects, including:\n\n* JDK types: int/double/BigDecimal/boolean/String etc\n* Custom types: POJO, [except for records support](https://github.com/j-easy/easy-random/issues/397)\n* Generic collections: List/Set/Stream/Array\n* [Java Faker](https://github.com/DiUS/java-faker) support: Name, Internet, Address etc\n* [Data Faker](https://github.com/datafaker-net/datafaker/) support: Name, Internet, Address etc\n* Javax/Jakarta Validation annotations: @Email, @Pattern etc\n* Custom Annotation with Validation annotation, such as @Phone. For more https://any86.github.io/any-rule/\n\n```java\n@Documented\n@Constraint(validatedBy = {})\n@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})\n@Retention(RUNTIME)\n@Pattern(regexp = \"^1[3-9]\\\\d{9}$\")\npublic @interface Phone {\n}\n```\n\n* i18n friendly to Faker's types\n\n```groovy\nimport com.github.javafaker.Address  \n  \n@Test\npublic void testAddress(@Random(locale = \"zh_CN\") Address address) {\n  System.out.println(address.cityName());\n}\n```\n\n# How to use?\n\nInclude following dependency in your pom.xml\n\n```xml\n  \u003cdependency\u003e\n    \u003cgroupId\u003eorg.mvnsearch\u003c/groupId\u003e\n    \u003cartifactId\u003eeasy-random-junit5-extension\u003c/artifactId\u003e\n    \u003cversion\u003e0.5.0\u003c/version\u003e\n    \u003c!--\u003cversion\u003e0.2.0\u003c/version\u003e for Java 8 \u0026 11--\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n  \u003c/dependency\u003e\n```\n\n# Usage examples:\n\n* Injecting random values as fields:\n\n```java\n   import org.jeasy.random.EasyRandomExtension;\n   import org.jeasy.random.Random;\n\n   @ExtendWith(EasyRandomExtension.class)\n   public class MyTest {\n  \n       @Random\n       private String anyString;\n  \n       @Random\n       private List\u003cDomainObject\u003e domainObjectList;\n       \n       @Test\n       public void testUsingRandomString() {\n           // use the injected anyString\n           // ...\n       }\n  \n       @Test\n       public void testUsingRandomDomainObjects() {\n           // use the injected anyDomainObjects\n           // the anyDomainObjects will contain _N_ fully populated random instances of DomainObject\n           // ...\n       }\n  \n       @Test\n       public void testUsingPartiallyPopulatedDomainObject() {\n           // use the injected anyPartiallyPopulatedDomainObject\n           // this object's \"name\" and \"value\" members will not be populated since this has been declared with\n           //     excluded = {\"name\", \"value\"}\n           // ...\n       }\n   }\n\n```\n\n* Injecting random values as parameters:\n\n```java\n   @ExtendWith(EasyRandomExtension.class)\n   public class MyTest {\n  \n       @Test\n       public void testUsingRandomString(@Random @Email String anyString) {\n           // use the provided anyString\n           // ...\n       }\n  \n       @Test\n       public void testUsingRandomDomainObjects(@Random List\u003cDomainObject\u003e anyDomainObjects) {\n           // use the injected anyDomainObjects\n           // the anyDomainObjects will contain _N_ fully populated random instances of DomainObject\n           // ...\n       }\n   }\n```\n\n# JUnit 5 Automatic Extension Registration\n\nWith Automatic Extension Registration, and you can remove `@ExtendWith(EasyRandomExtension.class)` on test class.\n\n* Create `src/test/resources/junit-platform.properties` with following code:\n\n```properties\njunit.jupiter.extensions.autodetection.enabled=true\n```\n\n* Remove `@ExtendWith(EasyRandomExtension.class)` on test class\n\n# References and Thanks\n\n* Easy Random: https://github.com/j-easy/easy-random\n* RandomBeansExtension: https://glytching.github.io/junit-extensions/randomBeans\n* Instancio: a Java library for automating data setup in unit tests https://www.instancio.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Feasy-random-junit5-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinux-china%2Feasy-random-junit5-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Feasy-random-junit5-extension/lists"}