{"id":23244654,"url":"https://github.com/bytemechanics/test-drive","last_synced_at":"2025-04-06T00:16:40.764Z","repository":{"id":57739041,"uuid":"153570001","full_name":"bytemechanics/test-drive","owner":"bytemechanics","description":"Pure Java, zero dependencies testing library","archived":false,"fork":false,"pushed_at":"2019-02-19T19:13:13.000Z","size":575,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T06:24:24.398Z","etag":null,"topics":["java","test-drive","unit-testing"],"latest_commit_sha":null,"homepage":null,"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/bytemechanics.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":"2018-10-18T05:49:36.000Z","updated_at":"2018-11-12T16:19:02.000Z","dependencies_parsed_at":"2022-08-24T17:40:17.423Z","dependency_job_id":null,"html_url":"https://github.com/bytemechanics/test-drive","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytemechanics%2Ftest-drive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytemechanics%2Ftest-drive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytemechanics%2Ftest-drive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytemechanics%2Ftest-drive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytemechanics","download_url":"https://codeload.github.com/bytemechanics/test-drive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415967,"owners_count":20935387,"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":["java","test-drive","unit-testing"],"created_at":"2024-12-19T07:10:10.973Z","updated_at":"2025-04-06T00:16:40.744Z","avatar_url":"https://github.com/bytemechanics.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Copy Commons\n[![Latest version](https://maven-badges.herokuapp.com/maven-central/org.bytemechanics/test-drive/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.bytemechanics/test-drive/badge.svg)\n[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=org.bytemechanics%3Atest-drive-parent\u0026metric=alert_status)](https://sonarcloud.io/dashboard/index/org.bytemechanics%3Atest-drive-parent)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=org.bytemechanics%3Atest-drive-parent\u0026metric=coverage)](https://sonarcloud.io/dashboard/index/org.bytemechanics%3Atest-drive-parent)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nPure java testing framework implementation\n\n## Motivation\nSpock framework is fantastic but use groovy to test java always will be become a mess. After executing a test that should fail and does not fail. Decided that this must be done in pure java.\n\n## Quick start\n(Please read our [Javadoc](https://test-drive.bytemechanics.org/docs/javadoc/index.html) for further information)\n\n1. First of all include the Jar file in your compile and execution classpath.\n\n   **Maven**\n   ```xml\n   \u003cdependency\u003e\n\t   \u003cgroupId\u003eorg.bytemechanics\u003c/groupId\u003e\n\t   \u003cartifactId\u003etest-drive\u003c/artifactId\u003e\n\t   \u003cversion\u003eX.X.X\u003c/version\u003e\n\t   \u003ctype\u003etest\u003c/type\u003e\n   \u003c/dependency\u003e\n   ```\n\n2. In your maven pom.xml activate the surefire test-drive provider by adding the corresponding dependency\n\n   ```xml\n\t\u003cbuild\u003e\n\t\t\u003cplugins\u003e\n\t\t\t\u003cplugin\u003e\n\t\t\t\t\u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n\t\t\t\t\u003cartifactId\u003emaven-surefire-plugin\u003c/artifactId\u003e\n\t\t\t\t\u003cversion\u003eX.XX.X\u003c/version\u003e\n\t\t\t\t(...)\n\t\t\t\t\u003cdependencies\u003e\n\t\t\t\t\t\u003cdependency\u003e\n\t\t\t\t\t\t\u003cgroupId\u003eorg.bytemechanics\u003c/groupId\u003e\n\t\t\t\t\t\t\u003cartifactId\u003etestdrive-surefire\u003c/artifactId\u003e\n\t\t\t\t\t\t\u003cversion\u003eX.X.X\u003c/version\u003e\n\t\t\t\t\t\u003c/dependency\u003e\n\t\t\t\t\u003c/dependencies\u003e\n\t\t\t\u003c/plugin\u003e\n\t\t\u003c/plugins\u003e\n\t\u003c/build\u003e\n   ```\n\n3. In your maven pom.xml activate the suffix you will use (tipically Spec)\n\n   ```xml\n\t\u003cbuild\u003e\n\t\t\u003cplugins\u003e\n\t\t\t\u003cplugin\u003e\n\t\t\t\t\u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n\t\t\t\t\u003cartifactId\u003emaven-surefire-plugin\u003c/artifactId\u003e\n\t\t\t\t\u003cversion\u003eX.XX.X\u003c/version\u003e\n\t\t\t\t\u003cconfiguration\u003e\n\t\t\t\t\t\u003cincludes\u003e\n\t\t\t\t\t\t\u003cinclude\u003e*Spec.java\u003c/include\u003e\n\t\t\t\t\t\t(...)\n\t\t\t\t\t\u003c/includes\u003e\n\t\t\t\t\u003c/configuration\u003e\n\t\t\t\t(...)\n\t\t\t\u003c/plugin\u003e\n\t\t\u003c/plugins\u003e\n\t\u003c/build\u003e\n   ```\n\n4. Create your first spec\n   * Option 1: non-driven\n\n     ```Java\n     import org.bytemechanics.testdrive.Specification;\n     import org.bytemechanics.testdrive.annotations.Evaluation;\n     import org.bytemechanics.testdrive.annotations.Test;\n     import org.bytemechanics.testdrive.Assert;\n\n     public class AddIntegerSpec implements Specification {\n\n        (...)\n\n     \t@Test(name=\"accumulate {} and {} should result with {} with driven test\", evaluations = {\n     \t\t@Evaluation(name = \"one\",args = {\"1\",\"1\",\"0\",\"2\"}),\n     \t\t@Evaluation(name = \"zero\",args = {\"0\",\"0\",\"0\",\"0\"})\n     \t})\n     \tpublic void accumulate(final int _base,final int _val1,final int _val2,final int _expected){\n\n\t\t\tint base=_base;\n\t\t\tint actual=base+_val1+_val2;\n\t\t\tAssert.assertEquals(actual,_expected);\n     \t}\n        (...)\n     }\n     ```\n\n   * Option 2: non-driven with labels\n\n     ```Java\n     import org.bytemechanics.testdrive.Specification;\n     import org.bytemechanics.testdrive.annotations.Evaluation;\n     import org.bytemechanics.testdrive.annotations.Test;\n     import org.bytemechanics.testdrive.Assert;\n\n     public class AddIntegerSpec implements Specification {\n\n        (...)\n\n     \t@Test(name=\"accumulate {} and {} should result with {} with driven test\", evaluations = {\n     \t\t@Evaluation(name = \"one\",args = {\"1\",\"1\",\"0\",\"2\"}),\n     \t\t@Evaluation(name = \"zero\",args = {\"0\",\"0\",\"0\",\"0\"})\n     \t})\n     \tpublic void accumulate(final int _base,final int _val1,final int _val2,final int _expected){\n\n\t\t\tint base,actual;\n\n\t\t\tgiven:\n\t\t\t\tbase=_base;\n\t\t\twhen:\n\t\t\t\tactual=base+_val1+_val2;\n\t\t\tthen:\n\t\t\t\tAssert.assertEquals(actual,_expected);\n     \t}\n        (...)\n     }\n     ```\n\n   * Option 3: driven\n\n     ```Java\n     import org.bytemechanics.testdrive.DrivenTest;\n     import org.bytemechanics.testdrive.Specification;\n     import org.bytemechanics.testdrive.annotations.Evaluation;\n     import org.bytemechanics.testdrive.annotations.Test;\n     import org.bytemechanics.testdrive.example.AddInteger;\n     import org.bytemechanics.testdrive.exceptions.AssertException;\n     import org.bytemechanics.testdrive.Assert;\n\n     public class AddIntegerSpec implements Specification {\n\n        (...)\n\n     \t@Test(name=\"accumulate {} and {} should result with {} with driven test\", evaluations = {\n     \t\t@Evaluation(name = \"one\",args = {\"1\",\"1\",\"0\",\"2\"}),\n     \t\t@Evaluation(name = \"zero\",args = {\"0\",\"0\",\"0\",\"0\"})\n     \t})\n\t\tpublic DrivenTest accumulateDriven(final int _base,final int _val1,final int _val2,final int _expected){\n\t\t\treturn new DrivenTest() {\n\n\t\t\t\tint base,actual;\n\n\t\t\t\t@Override\n\t\t\t\tpublic void given() {\n\t\t\t\t\tthis.base=_base;\n\t\t\t\t}\n\t\t\t\t@Override\n\t\t\t\tpublic void when() {\n\t\t\t\t\tthis.actual=this.base+_val1+_val2;\n\t\t\t\t}\n\t\t\t\t@Override\n\t\t\t\tpublic void then() throws AssertException {\n\t\t\t\t\tAssert.assertEquals(this.actual,_expected);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n        (...)\n     }\n     ```\n\nFor additional information please refer example project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytemechanics%2Ftest-drive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytemechanics%2Ftest-drive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytemechanics%2Ftest-drive/lists"}