{"id":19263653,"url":"https://github.com/soundvibe/pbt4j","last_synced_at":"2025-06-24T15:05:49.162Z","repository":{"id":57737775,"uuid":"53251236","full_name":"soundvibe/pbt4j","owner":"soundvibe","description":"pbt4j is property-based testing extensions for JUnit","archived":false,"fork":false,"pushed_at":"2016-08-30T18:03:40.000Z","size":37,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T19:13:57.640Z","etag":null,"topics":["java","junit","nashorn","property-based-testing","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/soundvibe.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":"2016-03-06T11:25:43.000Z","updated_at":"2016-03-09T14:50:41.000Z","dependencies_parsed_at":"2022-08-24T15:00:42.934Z","dependency_job_id":null,"html_url":"https://github.com/soundvibe/pbt4j","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/soundvibe/pbt4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundvibe%2Fpbt4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundvibe%2Fpbt4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundvibe%2Fpbt4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundvibe%2Fpbt4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soundvibe","download_url":"https://codeload.github.com/soundvibe/pbt4j/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundvibe%2Fpbt4j/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261700469,"owners_count":23196501,"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","junit","nashorn","property-based-testing","unit-testing"],"created_at":"2024-11-09T19:36:26.445Z","updated_at":"2025-06-24T15:05:49.135Z","avatar_url":"https://github.com/soundvibe.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.soundvibe/pbt4j/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.soundvibe/pbt4j)\n[![Build Status](https://travis-ci.org/soundvibe/pbt4j.png)](https://travis-ci.org/soundvibe/pbt4j)\n[![Join the chat at https://gitter.im/soundvibe/pbt4j](https://badges.gitter.im/soundvibe/pbt4j.svg)](https://gitter.im/soundvibe/pbt4j?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n# pbt4j\n\nProperty-based testing extensions for JUnit.\npbt4j allows you to add parameters to your test methods. You can either provide your parameter's values using annotations or\nthey will be randomly generated. You can also control how many times tests are being run (default value is 100 times).\nWhen providing custom test values, pbt4j uses Nashorn's JavaScript engine to resolve them so possibilities are almost endless.\n\nLearn more about pbt4j on the [Wiki home](https://github.com/soundvibe/pbt4j/wiki).\n\n## Getting started\n\n```java\nimport org.junit.*;\nimport org.junit.runner.RunWith;\nimport pbt4j.PropertyBasedTesting;\nimport pbt4j.annotations.*;\nimport java.util.*;\nimport static org.junit.Assert.*;\n\n@RunWith(PropertyBasedTesting.class)\n@JsEval(\"var Foo = Java.type('pbt4j.Foo'); var Bean = Java.type('pbt4j.Bean');\")\n//we can optionally register our custom types in js context if we want to provide them using @JsData annotation\npublic class PropertyBasedTestingTest {\n    @Test\n    public void shouldProvideTwoArguments(\n           @JsData({\"1\", \"2\"}) long numbers,\n           @JsData({\"'foo'\", \"'bar'\"}) String strings) {\n        System.out.println(\"arg1: \" + numbers);\n        System.out.println(\"arg2: \" + strings);\n        //first run prints:\n        // arg1: 1\n        // arg2: foo\n        //second run prints:\n        // arg1: 2\n        // arg2: bar\n    }\n\n    @Test\n    public void shouldProvideListsOfArguments(\n            @JsData({\"['foo', 'bar']\", \"['second', 'third']\"}) List\u003cString\u003e arg,\n            @JsData({\"[1, 2]\", \"[3, 4]\"}) List\u003cInteger\u003e numbers) {\n\n        assertEquals(2, arg.size());\n        assertEquals(2, numbers.size());\n\n        System.out.println(arg);\n        System.out.println(numbers);\n        //first run prints:\n        // [foo, bar]\n        // [1, 2]\n        //second run prints:\n        // [second, third]\n        // [3, 4]\n    }\n\n    @Test\n    @Repeat(times = 10)\n    public void shouldProvideRandomValuesAndCallMethod10Times(int number) throws Exception {\n        System.out.println(number);\n        //Prints 10 random numbers\n    }\n\n    @Test\n    public void shouldProvideCustomClass(Foo foo) throws Exception {\n        System.out.println(foo);\n        //prints randomly generated Foo 100 times\n    }\n\n    @Test\n    public void shouldProvideMap(\n            @JsonData({\"{foo: 'bar', second: 'bar2'}\"}) Map\u003cString, String\u003e map) throws Exception {\n        assertEquals(HashMap.class, map.getClass());\n        assertEquals(\"bar\", map.get(\"foo\"));\n        assertEquals(\"bar2\", map.get(\"second\"));\n    }\n\n    @Test\n    public void shouldProvideCustomClassUsingJs(\n            @JsData({\"new Foo('Foo', 28, [new Bean()], null)\"}) Foo foo) throws Exception {\n        assertEquals(\"Foo\", foo.name);\n        assertEquals(28, foo.age);\n        assertEquals(Foo.class, foo.getClass());\n    }\n\n}\n```\n\n## Binaries\n\nBinaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cnet.soundvibe.reacto).\n\nExample for Gradle:\n\n```groovy\ncompile 'net.soundvibe:pbt4j:x.y.z'\n```\n\nand for Maven:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003enet.soundvibe\u003c/groupId\u003e\n    \u003cartifactId\u003epbt4j\u003c/artifactId\u003e\n    \u003cversion\u003ex.y.z\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\n## Bugs and Feedback\n\nFor bugs, questions and discussions please use the [Github Issues](https://github.com/soundvibe/pbt4j/issues).\n\n## LICENSE\n\nCopyright 2016 Linas Naginionis\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n\u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundvibe%2Fpbt4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoundvibe%2Fpbt4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundvibe%2Fpbt4j/lists"}