{"id":16536752,"url":"https://github.com/eliasnogueira/example-test-data-builder","last_synced_at":"2025-10-03T20:50:22.313Z","repository":{"id":45352212,"uuid":"228998684","full_name":"eliasnogueira/example-test-data-builder","owner":"eliasnogueira","description":"How to implement and use Test Data Builder","archived":false,"fork":false,"pushed_at":"2023-12-25T13:39:58.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-07T07:20:54.293Z","etag":null,"topics":["data","testautomation","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","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/eliasnogueira.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":"2019-12-19T07:23:39.000Z","updated_at":"2025-05-15T19:23:35.000Z","dependencies_parsed_at":"2024-11-14T10:52:39.054Z","dependency_job_id":null,"html_url":"https://github.com/eliasnogueira/example-test-data-builder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eliasnogueira/example-test-data-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fexample-test-data-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fexample-test-data-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fexample-test-data-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fexample-test-data-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eliasnogueira","download_url":"https://codeload.github.com/eliasnogueira/example-test-data-builder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fexample-test-data-builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278227254,"owners_count":25951883,"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-03T02:00:06.070Z","response_time":53,"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":["data","testautomation","testing"],"created_at":"2024-10-11T18:33:10.673Z","updated_at":"2025-10-03T20:50:22.257Z","avatar_url":"https://github.com/eliasnogueira.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to create a Test Data Builder\n\n## Environment\n\n * Maven\n * Java JDK 21+\n * Lombok plugin\n * Enable _Annotation Processing_\n \n## Project Structure\nThe project structure is described in a logical way showing how is the easiest way to create an object with data to use in your test and, in the end, the recommendation using the Test Data Builder. \n\n### src/main\n\n#### model/plain\nThe `UserRegistration` class is a plain object with _getters_ and _setters_, _constructor_ and _toString()_.\n\nThe `UserRegistrationBuilder` is the Builder pattern applied using the `UserRegistration` class to make easier the object creation.\n\n\u003e :warning: This approach is not recommended but if you're not used to creating Java classes, this might be helpful.\n\n#### model/lombok\nTo avoid you to write get, setters, toString, and builders you can use Lombok.\nOn the `UserRegistration` class you can see the `@Data` and `Builder` that, respectively, automatically create the get \nand setters, and the builder.\n\n\u003e :warning: This approach is not recommended. The only difference between this and the plain approach is that now we are \nusing less code.\n\n### data\nThis package contains the Test Data Builder classes.\nBoth classes on this package use `UserRegister` object created with Lombok.\n\nThe `UserRegistrationFixedData` has all the methods to create different data but with fixed data, \nwhich means your tests will have the same data all the time.\n\nThe `UserRegistrationData` has all the methods to create different dynamic data. Faker is being used to generate the data.\nEven though you use the same method twice in your test, the data will be different.\n\n### src/test\n\n#### plain\nThe class `PlainClassTest` shows how is the process to create a test with data to use in your test **in the regular way**.\n\nThe class `PlainClassUsingBuilderTest` shows how is the process to create a test with **data using a builder**.\n\n#### lombok\nThe class `UsingLombokBuilderTest` shows the same approach of the previous one, but using lombok with the builder in order to have less code.\n\n#### data\nThe class `UsingFixedDataTest` shows how is the process to **create a test with the Test Data Builder having fixed data**.\n\nThis class is being used on `UsingDynamicDataTest` to show how is the process to **create a test with the Test Data Builder having dynamic data**.\n\n### resources\nLog4J2 properties files used to show the log information in the console.\nNote that Log4J2 is being using directly on test classes `PlainClassTest`, `PlainClassUsingBuilderTest` and `UsingLombokBuilderTest` but when we \nstart using a concrete example of the Test Data Builder the log is being used on these tests.\n\nI created this approach to add the responsibility of the data longing in the right place: the place they are being generated.\n\n## References\n * https://martinfowler.com/bliki/ObjectMother.html\n * https://reflectoring.io/objectmother-fluent-builder\n * https://blog.codeleak.pl/2014/06/test-data-builders-and-object-mother.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliasnogueira%2Fexample-test-data-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliasnogueira%2Fexample-test-data-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliasnogueira%2Fexample-test-data-builder/lists"}