com.hackerrank.applications:junit-ordered-test-runner

An application to provide support for executing tests in the specific order and generate the customized XML report.

Лицензия

Лицензия

Категории

Категории

JUnit Тестирование компонентов
Группа

Группа

com.hackerrank.applications
Идентификатор

Идентификатор

junit-ordered-test-runner
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

com.hackerrank.applications:junit-ordered-test-runner
An application to provide support for executing tests in the specific order and generate the customized XML report.
Ссылка на сайт

Ссылка на сайт

http://github.com/interviewstreet/junit-ordered-test-runner/tree/master
Система контроля версий

Система контроля версий

http://github.com/interviewstreet/junit-ordered-test-runner/tree/master

Скачать junit-ordered-test-runner

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.hackerrank.applications/junit-ordered-test-runner/ -->
<dependency>
    <groupId>com.hackerrank.applications</groupId>
    <artifactId>junit-ordered-test-runner</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.hackerrank.applications/junit-ordered-test-runner/
implementation 'com.hackerrank.applications:junit-ordered-test-runner:1.0.2'
// https://jarcasting.com/artifacts/com.hackerrank.applications/junit-ordered-test-runner/
implementation ("com.hackerrank.applications:junit-ordered-test-runner:1.0.2")
'com.hackerrank.applications:junit-ordered-test-runner:jar:1.0.2'
<dependency org="com.hackerrank.applications" name="junit-ordered-test-runner" rev="1.0.2">
  <artifact name="junit-ordered-test-runner" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.hackerrank.applications', module='junit-ordered-test-runner', version='1.0.2')
)
libraryDependencies += "com.hackerrank.applications" % "junit-ordered-test-runner" % "1.0.2"
[com.hackerrank.applications/junit-ordered-test-runner "1.0.2"]

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
com.fasterxml.jackson.core : jackson-databind jar 2.9.6
commons-lang : commons-lang jar 2.6
org.jdom : jdom jar 1.1

Модули Проекта

Данный проект не имеет модулей.

JUnit Ordered Test Runner

An application to provide support for executing tests in the specific order and generate the customized XML report.

Installation

<dependency>
    <groupId>com.hackerrank.applications</groupId>
    <artifactId>junit-ordered-test-runner</artifactId>
    <version>1.0.2</version>
</dependency>
compile 'com.hackerrank.applications:junit-ordered-test-runner:1.0.2'
compile(group = "com.hackerrank.applications", name = "junit-ordered-test-runner", version = "1.0.2")
libraryDependencies += "com.hackerrank.applications" % "junit-ordered-test-runner" % "1.0.2"
<dependency org="com.hackerrank.applications" name="junit-ordered-test-runner" rev="1.0.2" />
@Grapes(
  @Grab(group='com.hackerrank.applications', module='junit-ordered-test-runner', version='1.0.2')
)
'com.hackerrank.applications:junit-ordered-test-runner:jar:1.0.2'

Sample Usage

  • 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.
  • Run the tests with TestWatcher rule using @Rule annotation.
  • Register the test class using the registerClass method of TestWatcher in the @BeforeClass setup.
  • Finally, invoke the createReport method of TestWatcher in the @AfterClass setup.

For example,

@RunWith(OrderedTestRunner.class)
public class SampleOrderedTest {

    @Rule
    public TestWatcher watchman = TestWatchman.watchman;

    public SampleOrderedTest() {
    }

    @BeforeClass
    public static void setUpClass() {
        TestWatchman.watchman.registerClass(SampleOrderedTest.class);
    }

    @AfterClass
    public static void tearDownClass() {
        TestWatchman.watchman.createReport(SampleOrderedTest.class);
    }

    @Test
    @Order(1)
    public void firstTest() {
        assertTrue(0 == 0);
    }

    @Test
    @Order(2)
    public void secondTest() {
        assertEquals(1, 1);
    }

    @Test
    @Ordered(3)
    public void thirdTest() {
        assertNotEquals(1, null);
    }
}

Also,

  • 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.

For example,

public class SampleOrderedTest {

    public SampleOrderedTest() {
    }

    @BeforeClass
    public static void setUpClass() {
        TestWatchman.watchman.registerClass(SampleOrderedTest.class);
    }

    @AfterClass
    public static void tearDownClass() {
        TestWatchman.watchman.createReport(SampleOrderedTest.class);
    }

    @Test
    public void startTest() {
        JUnitCore.runClasses(TestHelper.class);

        assertTrue(TestWatchman.watchman.allTestsSucceeded());
    }

    @RunWith(OrderedTestRunner.class)
    public static class TestHelper {

        @Rule
        public TestWatcher watchman = TestWatchman.watchman;

        @Test
        @Order(1)
        public void firstTest() {
            assertTrue(0 == 0);
        }

        @Test
        @Order(3)
        public void thirdTest() {
            assertNotEquals(1, null);
        }

        @Test
        @Order(2)
        public void secondTest() {
            assertEquals(1, 1);
        }
    }
}

And,

  • When some tests are not assigned an order, then, these are run after the tests with an assigned order.

You can refer the given test examples for better understanding of writing tests with OrderedTestRunner.

Report Generation

  • The TestWatcher generates an XML report in the target/hackerrank-report directory. The filename is TEST-{test-class-canonical-name}.xml.
  • When running tests in a suite, suite report, as well as individual test reports, will be generated.

Building Project

  • Use mvn clean build to build the project.
  • Use mvn clean test to run the tests.
  • Use mvn clean test -Dtest=TestSuite to run the suite.
com.hackerrank.applications

HackerRank

Match Every Developer to the Right Job.

Версии библиотеки

Версия
1.0.2
1.0.1
1.0.0