{"id":18012867,"url":"https://github.com/tonivade/purecheck","last_synced_at":"2025-06-23T08:38:26.794Z","repository":{"id":37103759,"uuid":"285252225","full_name":"tonivade/purecheck","owner":"tonivade","description":"Property based testing in Java","archived":false,"fork":false,"pushed_at":"2024-10-22T05:51:18.000Z","size":863,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-23T08:05:55.525Z","etag":null,"topics":["experimental","functional-programming","java","property-based-testing","unit-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/tonivade.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-05T10:12:49.000Z","updated_at":"2024-10-22T05:51:15.000Z","dependencies_parsed_at":"2024-01-23T08:27:56.659Z","dependency_job_id":"bfb6a838-af9a-4654-850f-793caa1f6aa2","html_url":"https://github.com/tonivade/purecheck","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonivade%2Fpurecheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonivade%2Fpurecheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonivade%2Fpurecheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonivade%2Fpurecheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonivade","download_url":"https://codeload.github.com/tonivade/purecheck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222155978,"owners_count":16940425,"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":["experimental","functional-programming","java","property-based-testing","unit-testing"],"created_at":"2024-10-30T03:19:21.384Z","updated_at":"2024-10-30T03:19:21.934Z","avatar_url":"https://github.com/tonivade.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# purecheck\n\nThe idea of this project is try to implement unit testing thinking in tests like pure values, \ninstead of statements, no annotations, no runtime bytecode manipulation.\n\nPure values have some improvements, for example, it's pretty easy to retry in case of some\nflaky tests, or repeat the test, or measure the time the computation it takes.\n\nSo, a test case can be defined as a function that eventually returns a result, like this:\n\n```scala\n  type TestCase[E, T] = IO[TestResult[E, T]]\n```\n\nE is the type of the error generated by the test, and T the value generated by the computation\nunder test.\n\nBut in Java there are no type aliases, though we can create a class `TestCase` and wrap the value:\n\n```java\n  public class TestCase\u003cE, T\u003e {\n    \n    private final IO\u003cTestResult\u003cE, T\u003e\u003e test;\n    \n    //...\n  }\n```\n\n`TestResult\u003cE, T\u003e` can have 4 different values:\n\n - `Success` when everything is ok, \n - `Failure` when the validations fail, \n - `Error` when the execution of the computation throws an error, \n - `Disabled` when the test is disabled.\n \nThis a simple example:\n \n ```java\n  TestSuite\u003cString\u003e suite = suite(\"NonEmptyString\",\n\n      it.should(\"not accept null\")\n          .\u003cString\u003egivenNull()\n          .when(NonEmptyString::of)\n          .thenThrows(instanceOf(IllegalArgumentException.class)),\n\n      it.should(\"not accept empty string\")\n          .given(\"\")\n          .when(NonEmptyString::of)\n          .thenThrows(instanceOf(IllegalArgumentException.class)),\n\n      it.should(\"contains a non empty string\")\n          .given(\"hola mundo\")\n          .when(NonEmptyString::of)\n          .then(equalsTo(\"hola mundo\").compose(NonEmptyString::get)),\n\n      it.should(\"map inner value\")\n          .given(NonEmptyString.of(\"hola mundo\"))\n          .when(hello -\u003e hello.map(String::toUpperCase))\n          .then(equalsTo(\"HOLA MUNDO\").compose(NonEmptyString::get)),\n\n      it.should(\"transform inner value\")\n          .given(NonEmptyString.of(\"hola mundo\"))\n          .when(hello -\u003e hello.transform(String::toUpperCase))\n          .then(equalsTo(\"HOLA MUNDO\")),\n\n      it.should(\"be equals to other string `hola mundo`\")\n          .given(NonEmptyString.of(\"hola mundo\"))\n          .noop()\n          .then(equalsTo(NonEmptyString.of(\"hola mundo\"))),\n\n      it.should(\"not be equals to other string different to `hola mundo`\")\n          .given(NonEmptyString.of(\"hola mundo\"))\n          .noop()\n          .then(notEqualsTo(NonEmptyString.of(\"HOLA MUNDO\")))\n  );\n ```\n \n Then you can run the suite and generate a test report:\n \n ```java\n  TestReport\u003cString\u003e report = suite.run();\n ```\n \n And the report generated looks like this:\n \n ```\n  NonEmptyString {\n    - it should 'not accept null' SUCCESS: 'java.lang.IllegalArgumentException: require non null'\n    - it should 'not accept empty string' SUCCESS: 'java.lang.IllegalArgumentException: require non empty string'\n    - it should 'contains a non empty string' SUCCESS: 'NonEmptyString(hola mundo)'\n    - it should 'map inner value' SUCCESS: 'NonEmptyString(HOLA MUNDO)'\n    - it should 'transform inner value' SUCCESS: 'HOLA MUNDO'\n    - it should 'be equals to other string `hola mundo`' SUCCESS: 'NonEmptyString(hola mundo)'\n    - it should 'not be equals to other string different to `hola mundo`' SUCCESS: 'NonEmptyString(hola mundo)'\n  }\n ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonivade%2Fpurecheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonivade%2Fpurecheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonivade%2Fpurecheck/lists"}