{"id":25776879,"url":"https://github.com/MichaelTamm/junit-toolbox","last_synced_at":"2025-02-27T06:06:59.447Z","repository":{"id":32801520,"uuid":"36393971","full_name":"MichaelTamm/junit-toolbox","owner":"MichaelTamm","description":"Useful classes for writing automated tests with JUnit 4","archived":false,"fork":false,"pushed_at":"2023-10-11T02:00:47.000Z","size":315,"stargazers_count":137,"open_issues_count":10,"forks_count":25,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-01-30T23:37:20.544Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MichaelTamm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-27T20:30:45.000Z","updated_at":"2024-01-13T23:53:51.000Z","dependencies_parsed_at":"2022-08-07T18:01:50.188Z","dependency_job_id":null,"html_url":"https://github.com/MichaelTamm/junit-toolbox","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelTamm%2Fjunit-toolbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelTamm%2Fjunit-toolbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelTamm%2Fjunit-toolbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelTamm%2Fjunit-toolbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MichaelTamm","download_url":"https://codeload.github.com/MichaelTamm/junit-toolbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987435,"owners_count":19889335,"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":"2025-02-27T06:01:32.682Z","updated_at":"2025-02-27T06:06:59.438Z","avatar_url":"https://github.com/MichaelTamm.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":[],"readme":"# Overview #\n\nThe JUnit Toolbox provides some useful classes for writing automated tests with JUnit:\n  * [MultithreadingTester](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/MultithreadingTester.html) -- Helper class for writing stress tests using multiple, concurrently running threads\n  * [PollingWait](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/PollingWait.html) -- Helper class to wait for asynchronous operations\n  * [ParallelRunner](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/ParallelRunner.html) -- Executes all `@Test` methods as well as the calls to `@Theory` methods  with different parameter assignments concurrently using several worker threads.\n  * [ParallelParameterized](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/ParallelParameterized.html) -- A replacement for the JUnit runner `Parameterized` which executes the tests for each parameter set concurrently.\n  * [WildcardPatternSuite](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/WildcardPatternSuite.html) -- A replacement for the JUnit runners `Suite` and `Categories`, which allows you to specify the children classes of your test suite class using a wildcard pattern. Furthermore you can include and/or exclude multiple categories.\n  * [ParallelSuite](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/ParallelSuite.html) -- An extension of the `WildcardPatternSuite`, which executes its children classes concurrently using several worker threads. Although it extends `WildcardPatternSuite` you are not forced to use a wildcard pattern, you can also list the children class using the `@SuiteClasses` annotation known from JUnit.\n  * [InnerTestClassesSuite](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/InnerTestClassesSuite.html) -- A replacement for the JUnit runner `Enclosed` which executes all inner test classes of the class annotated with ` @RunWith(InnerTestClassesSuite.class)`. In contrast to the `Enclosed` runner provided by JUnit it detects if an inner class is actually a test class and ignores all other inner classes.\n\n`ParallelRunner`, `ParallelParameterized`, and `ParallelSuite` share a common Fork-Join-Pool. You can control the maximum number of worker threads by specifying the system property `maxParallelTestThreads`. If this system property is not set, there will be as many worker threads as the number of processors available to the JVM.\n\n# How to use it #\n\nIf you use [Maven](http://maven.apache.org), add the following dependency to your `pom.xml` file:\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.googlecode.junit-toolbox\u003c/groupId\u003e\n    \u003cartifactId\u003ejunit-toolbox\u003c/artifactId\u003e\n    \u003cversion\u003e2.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n# Release Notes #\n\n## Version 2.4 (for Java 8) and Version 1.11 (for Java 6) ##\n * [WildcardPatternSuite](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/WildcardPatternSuite.html) can now handle wildcard patterns starting with \"../\" (fixes [#16](https://github.com/MichaelTamm/junit-toolbox/issues/16))\n * Fixed edge case where too many threads were created when using one of [ParallelRunner](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/ParallelRunner.html),  [ParallelParameterized](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/ParallelParameterized.html), or  [ParallelSuite](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/ParallelSuite.html) contributed by Till Klister \n\n## Version 2.3 (for Java 8) ##\n  * Improved handling of `AssumptionViolatedException` in [ParallelRunner](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/ParallelRunner.html) contributed by Christian Grotheer (fixes [#12](https://github.com/MichaelTamm/junit-toolbox/issues/12)).\n\n## Version 2.2 (for Java 8) and Version 1.10 (for Java 6) ##\n  * Updated to JUnit 4.12\n  * Improved [WildcardPatternSuite](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/WildcardPatternSuite.html): it now ignores classes, which match the specified wildcard pattern, but are not test classes (fixes issue #8)\n\n## Version 2.1 (for Java 8) and Version 1.9 (for Java 6) ##\n  * Added the [ParallelParameterized](//michaeltamm.github.io/junit-toolbox/com/googlecode/junittoolbox/ParallelParameterized.html) runner contributed by Stefan Birkner.\n\n## Version 2.0 ##\n  * Upgraded to Java 8. Note: This does not mean, that there won't be any new version for Java 6. If a new feature or bug fix (which is compatible to Java 6) is added to the code base, I will release a new 1.x version as well as a new 2.x version.\n  * Added overloaded `until` method to `PollingWait` which takes a `Callable\u003cBoolean\u003e` as parameter, which allows to use lambda expressions or method references. Example:\n```\nprivate PollingWait wait = new PollingWait().timeoutAfter(5, SECONDS)\n                                            .pollEvery(100, MILLISECONDS);\n\n@Test\npublic void test_login() throws Exception {\n    // ... enter credentials into login form ...\n    clickOnButton(\"Login\");\n    wait.until(() -\u003e webDriver.findElement(By.linkText(\"Logout\")).isDisplayed());\n    // ...\n}\n\nprotected void clickOnButton(String label) {\n    WebElement button = findButton(label);\n    wait.until(button::isDisplayed);\n    button.click();\n}\n```\n\n## Version 1.8 ##\n  * Fixed bug in `MultithreadingTester` introduced in version 1.5\n\n## Version 1.7 ##\n  * Added annotations `@IncludeCategories` and `@ExcludeCategories`. In contrast to JUnit 4, which only offers the annotations `@IncludeCategory` and `@ExcludeCategory` which allow to specify a single category, these new annotations allow you to specify multiple categories. The annotations can be used with `WildcardPatternSuite` and with `ParallelSuite`. Example:\n```\n@RunWith(WildcardPatternSuite.class)\n@SuiteClasses(\"**/*Test.class\")\n@ExcludeCategories({SlowTests.class, FlakyTests.class})\npublic class NormalTests {}\n```\n\n## Version 1.6 ##\n  * Minor bugfixes in `PollingWait` class\n\n## Version 1.5 ##\n  * Added deadlock detection to `MultithreadingTester`\n\n## Version 1.4 ##\n  * Added new utility class `MultithreadingTester`\n  * The `SuiteClasses` annotation accepts multiple wildcard patterns now as well as negated patterns. E.g.\n```\n@RunWith(WildcardPatternSuite.class)\n@SuiteClasses({\"**/*Test.class\", \"!samples/**\"})\npublic class AllTests {}\n```\n\n## Version 1.3 ##\n\n  * Added `PollingWait` and `RunnableAssert` for waiting that an asynchronous operation succeeds. Unlike the `WebDriverWait` class provided by [Selenium](https://selenium.googlecode.com) this class does not wait for an artificial condition, which might be wrong and can make your test non-deterministic, this class waits until your assertions become true (or a configurable timeout is reached). Example:\n```\nprivate PollingWait wait = new PollingWait().timeoutAfter(5, SECONDS).pollEvery(100, MILLISECONDS);\n\n@Test\npublic void test_auto_complete() throws Exception {\n    // Enter \"cheese\" into auto complete field ...\n    ...\n    wait.until(new RunnableAssert(\"'cheesecake' is displayed in auto-complete \u003cdiv\u003e\") { @Override public void run() throws Exception {\n        WebElement autoCompleteDiv = driver.findElement(By.id(\"auto-complete\"));\n        assertThat(autoCompleteDiv, isVisible());\n        assertThat(autoCompleteDiv, containsText(\"cheesecake\"));\n    }});\n}\n```\n\n## Version 1.2 ##\n\n  * `ParallelRunner` extends the `Theories` runner provided by JUnit now, and can be used as a replacement for it. It still executes all normal `@Test` methods concurrently. Furthermore it executes the calls to `@Theory` methods with different parameter assignments concurrently too.\n\n## Version 1.1 ##\n  * The `WildcardPatternSuite` runner supports the annotations `@IncludeCategory` and `@ExcludeCategory` now and can therefore be used as a replacement for the `Categories` runner provided by JUnit. Example:\n```\n@RunWith(WildcardPatternSuite.class)\n@SuiteClasses(\"**/*Test.class\")\n@IncludeCategory(SlowTests.class)\npublic class OnlySlowTests {}\n```\n  * New runner `InnerTestClassesSuite` which runs all inner test classes of the class annotated with `@RunWith(InnerTestClassesSuite\u0026#46;class)`. In contrast to the `Enclosed` runner provided by JUnit, it detects if an inner class is actually a test class and ignores all other inner classes. Example:\n```\n@RunWith(InnerTestClassesSuite.class)\npublic class LoginBeanTests {\n\n    public static class UnitTests {\n        @Test\n        public void test1() { ... }\n    }\n\n    @Configuration\n    public static class IntegrationTestsConfig { ... }\n\n    @RunWith(SpringJUnit4ClassRunner.class)\n    @ContextConfiguration(classes = IntegrationTestsConfig.class)\n    public static class IntegrationTests {\n        @Test\n        public void test2() { ... }\n    }\n}\n```\n\n## Version 1.0 ##\n  * bundled with [JUnit](https://github.com/KentBeck/junit) 4.10, [Hamcrest](https://hamcrest.googlecode.com/) 1.3, and [Mockito](https://mockito.googlecode.com/) 1.9.5\n  * `WildcardPatternSuite` runner for specifying the children classes of a test suite with a [wildcard pattern](http://ant.apache.org/manual/dirtasks.html#patterns) like this:\n```\n@RunWith(WildcardPatternSuite.class)\n@SuiteClasses(\"**/*Test.class\")\npublic class AllTests {}\n```\n  * `ParallelSuite` for concurrent execution of test classes. You can either list the test classes, if you use the `@SuiteClasses` annotation provided by JUnit itself, for example:\n```\n@RunWith(ParallelSuite.class)\n@SuiteClasses({\n    LoginFrontendTest.class,\n    FillOutFormFrontendTest.class,\n    ...\n})\npublic class AllFrontendTests {}\n```\n\u003e or you can use a [wildcard pattern](http://ant.apache.org/manual/dirtasks.html#patterns) if you use the `@SuiteClasses` annotation of JUnit Toolbox:\n```\n@RunWith(ParallelSuite.class)\n@SuiteClasses(\"**/*FrontendTest.class\")\npublic class AllFrontendTests {}\n```\n  * `ParallelRunner` for concurrent execution of the test methods in a test class. Example:\n```\n@RunWith(ParallelRunner.class)\npublic class FooTest {\n    @Test\n    public void test1() {\n        // Will be executed in a worker thread\n    }\n    @Test\n    public void test2() {\n        // Will be executed concurrently in another worker thread\n    }\n}\n```\n  * `ParallelSuite` and `ParallelRunner` share a common Fork-Join-Pool (to be compatible with Java 6, the JSR-166y code is used). You can control the maximum number of worker threads by specifying the system property `maxParallelTestThreads`. If this system property is not set, there will be as many worker threads as the number of processors available to the JVM.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMichaelTamm%2Fjunit-toolbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMichaelTamm%2Fjunit-toolbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMichaelTamm%2Fjunit-toolbox/lists"}