Skip to content

ocarlsen/junit4-test-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

junit4-test-utils

Maven Central Build Quality Gate Status SonarCloud Coverage

Utilities for testing with JUnit 4.

Dependency Information

Maven

<dependency>
    <groupId>com.ocarlsen.test</groupId>
    <artifactId>junit4-test-utils</artifactId>
    <version>1.1-SNAPSHOT</version>
    <scope>test</scope>
</dependency>

Gradle

compile 'com.ocarlsen.test:junit4-test-utils:1.0-SNAPSHOT'

Example Code

Order

Use the com.ocarlsen.test.util.Order annotation in JUnit 4 (>= 4.13) like you would the org.junit.jupiter.api.Order annotation in JUnit 5.

@OrderWith(OrderAnnotation.class)
public class ExampleTest {

    private static int counter = -2;

    @BeforeClass
    public static void checkCounter_2() {
        assertThat(counter, is(-2));
    }

    @AfterClass
    public static void checkCounter2() {
        assertThat(++counter, is(2));
    }

    @Order(-1)
    @Test
    public void test_1() {
        assertThat(++counter, is(-1));
    }

    @Test
    public void test() {
        assertThat(++counter, is(0));
    }

    @Order(1)
    @Test
    public void test1() {
        assertThat(++counter, is(1));
    }
}

This example is demonstrated in ExampleTest.

About

Utilities for testing with JUnit 4

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages