{"id":13770449,"url":"https://github.com/square/burst","last_synced_at":"2025-05-11T03:32:45.461Z","repository":{"id":20533927,"uuid":"23813195","full_name":"square/burst","owner":"square","description":"A unit testing library for varying test data.","archived":true,"fork":false,"pushed_at":"2021-04-15T14:10:21.000Z","size":217,"stargazers_count":462,"open_issues_count":1,"forks_count":29,"subscribers_count":28,"default_branch":"master","last_synced_at":"2024-04-13T17:52:12.259Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/square.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-09T00:05:42.000Z","updated_at":"2024-03-31T14:15:11.000Z","dependencies_parsed_at":"2022-08-21T20:21:00.653Z","dependency_job_id":null,"html_url":"https://github.com/square/burst","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fburst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fburst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fburst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fburst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/square","download_url":"https://codeload.github.com/square/burst/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253514352,"owners_count":21920327,"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-08-03T17:00:37.621Z","updated_at":"2025-05-11T03:32:44.917Z","avatar_url":"https://github.com/square.png","language":"Java","funding_links":[],"categories":["Unit Test","Java","测试","Projects"],"sub_categories":["Library","Testing"],"readme":"Burst\n=====\n\nA unit testing library for varying test data.\n\n**DEPRECATED**: Burst remains stable and functional, but you should check out [TestParameterInjector](https://github.com/google/TestParameterInjector) from Google which is like Burst++. Unless there are major bugs in Burst which necessitate a patch release, no new development will be occurring.\n\n\n\nUsage\n-----\n\nBurst is a set of test runners which rely on enums for varying both the instantiation of test\nclasses and the methods inside of them.\n\nDefine an enum for the property you wish to vary.\n```java\npublic enum Soda {\n  PEPSI, COKE\n}\n```\nThe enum can be simple as above, or contain data and methods specific to what you are testing.\n```java\npublic enum Sets {\n  HASH_SET() {\n    @Override public \u003cT\u003e Set\u003cT\u003e create() {\n      return new HashSet\u003cT\u003e();\n    }\n  },\n  LINKED_HASH_SET() {\n    @Override public \u003cT\u003e Set\u003cT\u003e create() {\n      return new LinkedHashSet\u003cT\u003e();\n    }\n  },\n  TREE_SET() {\n    @Override public \u003cT\u003e Set\u003cT\u003e create() {\n      return new TreeSet\u003cT\u003e();\n    }\n  };\n\n  public abstract \u003cT\u003e Set\u003cT\u003e create();\n}\n```\n\nAnnotate your test class to use the `BurstJUnit4` runner.\n```java\n@RunWith(BurstJUnit4.class)\npublic class DrinkSodaTest {\n  // TODO Tests...\n}\n```\n\nAn enum that appears on a test constructor will cause all the enclosed test to be run once for each\nvalue in the enum.\n```java\npublic DrinkSodaTest(Soda soda) {\n  // TODO Do something with 'soda'...\n}\n```\n\nCombine multiple enums for the combination of their variations.\n```java\npublic DrinkSodaTest(Soda soda, Sets sets) {\n  // TODO Do something with 'soda' and 'sets'...\n}\n```\nThis will be called with the constructor arguments\n[`PEPSI` \u0026 `HASH_SET`, `PEPSI` \u0026 `LINKED_HASH_SET`, `PEPSI` \u0026 `TREE_SET`, `COKE` \u0026 `HASH_SET`, ..].\n\nIf your constructor is just setting fields, you can just annotate the fields with `@Burst`.\n```java\n@RunWith(BurstJUnit4.class)\npublic class DrinkSodaTest {\n  @Burst Soda soda;\n  @Burst Sets sets;\n  // TODO Tests...\n}\n```\nThis behaves just like the above example.\n\n**Note:** Classes can either have constructors with arguments *or* annotated fields. A class with both will cause the test runner to throw an exception.\n\nMethods may also be varied using one or more parameters that are enums.\n```java\n@Test public void drinkFavoriteSodas(Soda soda) {\n  // TODO Test drink method with 'soda'...\n}\n```\n\nHaving both constructor (or field) variation and method variation is supported.\n```java\n@RunWith(BurstJUnit4.class)\npublic class DrinkSodaTest {\n  private final Set\u003cSoda\u003e favorites;\n\n  public DrinkSodaTest(Sets sets) {\n    favorites = sets.create();\n  }\n\n  @Test public void trackFavorites() {\n    // TODO ...\n  }\n\n  @Test public void drinkFavoriteSodas(Soda soda) {\n    // TODO ...\n  }\n}\n```\nThe `trackFavorites` test will be executed 3 times, once for each `Sets` value. The\n`drinkFavoriteSodas` test, however, is executed 6 times, for each of the three `Sets` values it\nruns twice for each `Soda`.\n\nIf a particular variation or variation combination does not make sense you can use [assumptions][1]\nto filter either directly in the test or as a custom [rule][2].\n\n\n\nDownload\n--------\n\n *  **JUnit 4**\n\n    A test runner which can be used for JUnit 4.\n\n    ```\n    com.squareup.burst:burst-junit4:1.2.0\n    ```\n\n *  **Core library**\n\n    Contains the core logic which creates the combinations of arguments for both constructors and\n    method. Usually not useful on its own.\n\n    ```\n    com.squareup.burst:burst:1.2.0\n    ```\n\nSnapshots of the development version are available in [Sonatype's `snapshots` repository][snap].\n\n\n\nLicense\n-------\n\n    Copyright 2014 Square, Inc.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n\n\n [1]: http://junit.org/javadoc/latest/org/junit/Assume.html\n [2]: http://junit.org/javadoc/latest/org/junit/Rule.html\n [snap]: https://oss.sonatype.org/content/repositories/snapshots/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fburst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquare%2Fburst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fburst/lists"}