{"id":19736189,"url":"https://github.com/arnauld/org.technbolts.junit","last_synced_at":"2026-06-10T03:30:58.539Z","repository":{"id":11703887,"uuid":"14219477","full_name":"Arnauld/org.technbolts.junit","owner":"Arnauld","description":"JUnit utilities and Runner","archived":false,"fork":false,"pushed_at":"2014-05-14T22:11:52.000Z","size":212,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T18:59:06.666Z","etag":null,"topics":[],"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/Arnauld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-07T23:53:24.000Z","updated_at":"2014-05-14T22:11:52.000Z","dependencies_parsed_at":"2022-09-26T18:01:28.110Z","dependency_job_id":null,"html_url":"https://github.com/Arnauld/org.technbolts.junit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnauld%2Forg.technbolts.junit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnauld%2Forg.technbolts.junit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnauld%2Forg.technbolts.junit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnauld%2Forg.technbolts.junit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arnauld","download_url":"https://codeload.github.com/Arnauld/org.technbolts.junit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241062521,"owners_count":19902904,"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":[],"created_at":"2024-11-12T01:05:38.299Z","updated_at":"2026-06-10T03:30:58.496Z","avatar_url":"https://github.com/Arnauld.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JUnit extensions\n\nProvides utilities to enrich [Junit](http://junit.org/).\n\nAvailable through Maven Central:\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003eorg.technbolts\u003c/groupId\u003e\n      \u003cartifactId\u003ejunit\u003c/artifactId\u003e\n      \u003cversion\u003e1.0.1\u003c/version\u003e\n      \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \n\n## Parameterized test\n\nWhen running a parameterized test class, instances are created for the cross-product of\nthe test methods and the test data elements.\nCompared with the `org.junit.runner.Parameterized` (see [Junit Parameterized tests](https://github.com/junit-team/junit/wiki/Parameterized-tests))\n`org.technbolts.runner.Runner` allows both test class and test methods to be parameterized.\nFurthermore it is possible to use several and different `DataProvider` within the same test class,\nthus it is possible to test against different set of values.\n\n### Parameterized method\n\n```java\n@RunWith(Runner.class)\npublic class FibonacciMethodTest {\n    @Runner.DataProvider(name = \"fib-seq\")\n    public static Iterable\u003cObject[]\u003e data() {\n        return Arrays.asList(new Object[][]{\n                {0, 0}, {1, 1}, {2, 1},\n                {3, 2}, {4, 3}, {5, 5}, {6, 8}});\n    }\n\n    @Test\n    @Runner.Parameterized(dataProvider = \"fib-seq\", namePattern = \"{index}: fib({0})={1}\")\n    public void testFib(int value, int expected) {\n        assertThat(fib(value)).isEqualTo(expected);\n    }\n\n    public static int fib(int value) {\n        if (value == 0 || value == 1)\n            return value;\n        else\n            return fib(value - 1) + fib(value - 2);\n    }\n}\n```\n\n\n### Parameterized constructor\n\n```java\n@RunWith(Runner.class)\n@Runner.Parameterized(dataProvider = \"fib-seq\", namePattern = \"{index}: fib({0})={1}\")\npublic class FibonacciConstructorTest {\n    @Runner.DataProvider(name = \"fib-seq\")\n    public static Iterable\u003cObject[]\u003e data() {\n        return Arrays.asList(new Object[][]{\n                {0, 0}, {1, 1}, {2, 1},\n                {3, 2}, {4, 3}, {5, 5}, {6, 8}});\n    }\n\n    private final int value;\n    private final int expected;\n\n    public FibonacciConstructorTest(int value, int expected) {\n      this.value = value;\n      this.expected = expected;\n    }\n\n    @Test\n    public void testFib() {\n        assertThat(fib(value)).isEqualTo(expected);\n    }\n\n    public staic int fib(int value) {\n        if (value == 0 || value == 1)\n            return value;\n        else\n            return fib(value - 1) + fib(value - 2);\n    }\n}\n```\n\n### Parameterized Test combined with parameterized methods\n\n![Alt text](/doc/images/MultiDatabaseScriptsTest-resultTree.png \"Result tree screenshot\")\n\n```java\n@RunWith(Runner.class)\n@Runner.Parameterized(dataProvider = \"databases\")\npublic class MultiDatabaseScriptsTest {\n\n    @Runner.DataProvider(name = \"databases\")\n    public static Collection\u003cObject[]\u003e allDatabases() {\n        return Arrays.asList(o(\"db2\"), o(\"mysql\"), o(\"oracle\"), o(\"postgres\"));\n    }\n\n    private final String database;\n\n    public MultiDatabaseScriptsTest(String database) {\n        this.database = database;\n    }\n\n    @Runner.DataProvider(name = \"insertion-scripts\")\n    public static Collection\u003cObject[]\u003e insertions() {\n        return Arrays.asList(o(\"insert1.sql\"), o(\"insert2.sql\"));\n    }\n\n    @Test\n    @Runner.Parameterized(dataProvider = \"insertion-scripts\")\n    public void insert(String script) {\n        executeScript(script);\n    }\n\n    @Runner.DataProvider(name = \"migration-scripts\")\n    public static Collection\u003cObject[]\u003e migrations() {\n        return Arrays.asList(o(\"migration_01.sql\"), o(\"migration_02.sql\"));\n    }\n\n    @Test\n    @Runner.Parameterized(dataProvider = \"migration-scripts\")\n    public void migrate(String script) {\n        executeScript(script);\n    }\n\n    private static Object[] o(Object... objects) {\n        return objects;\n    }\n\n    private void executeScript(String script) {\n        //...\n    }\n\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnauld%2Forg.technbolts.junit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnauld%2Forg.technbolts.junit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnauld%2Forg.technbolts.junit/lists"}