{"id":22976466,"url":"https://github.com/interviewstreet/junit-ordered-test-runner","last_synced_at":"2025-04-02T08:20:53.946Z","repository":{"id":55590298,"uuid":"156777779","full_name":"interviewstreet/junit-ordered-test-runner","owner":"interviewstreet","description":"Utility for Ordered Test Execution","archived":false,"fork":false,"pushed_at":"2022-11-15T23:30:09.000Z","size":30,"stargazers_count":0,"open_issues_count":6,"forks_count":1,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-02-07T23:26:57.926Z","etag":null,"topics":["junit","junit-report","junit-runner"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interviewstreet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-08T22:33:51.000Z","updated_at":"2020-01-28T06:00:35.000Z","dependencies_parsed_at":"2022-08-15T03:50:37.062Z","dependency_job_id":null,"html_url":"https://github.com/interviewstreet/junit-ordered-test-runner","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fjunit-ordered-test-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fjunit-ordered-test-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fjunit-ordered-test-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fjunit-ordered-test-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interviewstreet","download_url":"https://codeload.github.com/interviewstreet/junit-ordered-test-runner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246777791,"owners_count":20832033,"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":["junit","junit-report","junit-runner"],"created_at":"2024-12-15T00:51:18.369Z","updated_at":"2025-04-02T08:20:53.925Z","avatar_url":"https://github.com/interviewstreet.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JUnit Ordered Test Runner\n\nAn application to provide support for executing tests in the specific order and generate the customized XML report.\n\n## Installation\n\n- [Apache Maven](maven.apache.org)\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.hackerrank.applications\u003c/groupId\u003e\n    \u003cartifactId\u003ejunit-ordered-test-runner\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n- [Gradle Groovy DSL](gradle.org)\n```\ncompile 'com.hackerrank.applications:junit-ordered-test-runner:1.0.2'\n```\n\n- [Gradle Kotlin DSL](github.com/gradle/kotlin-dsl)\n```\ncompile(group = \"com.hackerrank.applications\", name = \"junit-ordered-test-runner\", version = \"1.0.2\")\n```\n\n- [Scala SBT](scala-sbt.org)\n```\nlibraryDependencies += \"com.hackerrank.applications\" % \"junit-ordered-test-runner\" % \"1.0.2\"\n```\n\n- [Apache Ivy](ant.apache.org/ivy/)\n```\n\u003cdependency org=\"com.hackerrank.applications\" name=\"junit-ordered-test-runner\" rev=\"1.0.2\" /\u003e\n```\n\n- [Groovy Grape](groovy-lang.org/grape.html)\n```\n@Grapes(\n  @Grab(group='com.hackerrank.applications', module='junit-ordered-test-runner', version='1.0.2')\n)\n```\n\n- [Apache Builder](buildr.apache.org)\n```\n'com.hackerrank.applications:junit-ordered-test-runner:jar:1.0.2'\n```\n\n## Sample Usage\n\n- The `OrderedTestRunner` should be used to run the test. The order of each test can be set by the `@Order` annotation. The test with lower order value is run first.\n- Run the tests with `TestWatcher` rule using `@Rule` annotation.\n- Register the test class using the `registerClass` method of `TestWatcher` in the `@BeforeClass` setup.\n- Finally, invoke the `createReport` method of `TestWatcher` in the `@AfterClass` setup.\n\nFor example,\n\n```java\n@RunWith(OrderedTestRunner.class)\npublic class SampleOrderedTest {\n\n    @Rule\n    public TestWatcher watchman = TestWatchman.watchman;\n\n    public SampleOrderedTest() {\n    }\n\n    @BeforeClass\n    public static void setUpClass() {\n        TestWatchman.watchman.registerClass(SampleOrderedTest.class);\n    }\n\n    @AfterClass\n    public static void tearDownClass() {\n        TestWatchman.watchman.createReport(SampleOrderedTest.class);\n    }\n\n    @Test\n    @Order(1)\n    public void firstTest() {\n        assertTrue(0 == 0);\n    }\n\n    @Test\n    @Order(2)\n    public void secondTest() {\n        assertEquals(1, 1);\n    }\n\n    @Test\n    @Ordered(3)\n    public void thirdTest() {\n        assertNotEquals(1, null);\n    }\n}\n```\n\nAlso,\n\n- If a `Runner` is already being used to run the tests, then, an inner class can be used to run with `OrderedTestRunner`. Tests can be triggered using the `JUnitCore.runClasses` method. In this case, the test is always passing, so optional check can be performed using `allTestSucceeded`.\n\nFor example,\n\n```java\npublic class SampleOrderedTest {\n\n    public SampleOrderedTest() {\n    }\n\n    @BeforeClass\n    public static void setUpClass() {\n        TestWatchman.watchman.registerClass(SampleOrderedTest.class);\n    }\n\n    @AfterClass\n    public static void tearDownClass() {\n        TestWatchman.watchman.createReport(SampleOrderedTest.class);\n    }\n\n    @Test\n    public void startTest() {\n        JUnitCore.runClasses(TestHelper.class);\n\n        assertTrue(TestWatchman.watchman.allTestsSucceeded());\n    }\n\n    @RunWith(OrderedTestRunner.class)\n    public static class TestHelper {\n\n        @Rule\n        public TestWatcher watchman = TestWatchman.watchman;\n\n        @Test\n        @Order(1)\n        public void firstTest() {\n            assertTrue(0 == 0);\n        }\n\n        @Test\n        @Order(3)\n        public void thirdTest() {\n            assertNotEquals(1, null);\n        }\n\n        @Test\n        @Order(2)\n        public void secondTest() {\n            assertEquals(1, 1);\n        }\n    }\n}\n```\n\nAnd,\n\n- When some tests are not assigned an order, then, these are run after the tests with an assigned order.\n\nYou can refer the given [test examples](src/test/java/com/hackerrank/test/utility) for better understanding of writing tests with `OrderedTestRunner`.\n\n## Report Generation\n\n- The `TestWatcher` generates an XML report in the `target/hackerrank-report` directory. The filename is `TEST-{test-class-canonical-name}.xml`.\n- When running tests in a suite, suite report, as well as individual test reports, will be generated.\n\n## Building Project\n\n- Use `mvn clean build` to build the project.\n- Use `mvn clean test` to run the tests.\n- Use `mvn clean test -Dtest=TestSuite` to run the suite.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterviewstreet%2Fjunit-ordered-test-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterviewstreet%2Fjunit-ordered-test-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterviewstreet%2Fjunit-ordered-test-runner/lists"}