juniter

Framework that provides additional features to JUnit

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

org.eluder.juniter
ArtifactId

ArtifactId

juniter
Last Version

Last Version

1.1.2
Release Date

Release Date

Type

Type

pom
Description

Description

juniter
Framework that provides additional features to JUnit
Project URL

Project URL

https://github.com/trautonen/juniter
Project Organization

Project Organization

Tapio Rautonen
Source Code Management

Source Code Management

https://github.com/trautonen/juniter

Download juniter

Filename Size
juniter-1.1.2.pom 2 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/org.eluder.juniter/juniter/ -->
<dependency>
    <groupId>org.eluder.juniter</groupId>
    <artifactId>juniter</artifactId>
    <version>1.1.2</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/org.eluder.juniter/juniter/
implementation 'org.eluder.juniter:juniter:1.1.2'
// https://jarcasting.com/artifacts/org.eluder.juniter/juniter/
implementation ("org.eluder.juniter:juniter:1.1.2")
'org.eluder.juniter:juniter:pom:1.1.2'
<dependency org="org.eluder.juniter" name="juniter" rev="1.1.2">
  <artifact name="juniter" type="pom" />
</dependency>
@Grapes(
@Grab(group='org.eluder.juniter', module='juniter', version='1.1.2')
)
libraryDependencies += "org.eluder.juniter" % "juniter" % "1.1.2"
[org.eluder.juniter/juniter "1.1.2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.2

test (4)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.2
org.slf4j : jcl-over-slf4j jar 1.7.2
junit : junit jar 4.11
org.mockito : mockito-all jar 1.9.5

Project Modules

  • juniter-core
  • juniter-guice

juniter

Framework that extends JUnit functionality. Adds alternative approach for test rules, automatic mocking, context creation in guice and reflection assert utilities. The project juniter uses semantic versioning and tagging to provide clean version numbers.

Test life cycle

Test life cycle org.eluder.juniter.core.TestLifeCycle provides the hooks to different phases of a unit test. The main reason for custom interface over the JUnit org.junit.rules.TestRule interface is that the test rules do not allow access to the test instance.

Comparison between the TestLifeCycle and TestRule interfaces:

TestLifeCycle TestRule
Easy access to test instance yes no
Easy access to test class yes yes
Easy access to test method yes no
Must reset its own state after each test no yes
Requires a custom JUnit runner yes no

Usage

Core module requires the following dependency:

<dependency>
    <groupId>org.eluder.juniter</groupId>
    <artifactId>juniter-core</artifactId>
    <version>1.2.0-SNAPSHOT</version>
</dependency>

Using test life cycles requires defining the juniter test runner and defining the life cycles to use:

@RunWith(TestRunner.class)
@TestLifeCycles({ FirstLifeCycle.class, SecondLifeCycle.class })
public class MyTest {
    ...
}

Automatic mocking can be achieved with the shorthand mock runner or defining the mock life cycle as one test life cycle:

@RunWith(MockTestRunner.class)
public class MockTest {
    ...
}

is equivalent to

@RunWith(TestRunner.class)
@TestLifeCycles({ MockLifeCycle.class })
public class MockTest {
    ...
}

Guice integration requires the following dependency:

<dependency>
    <groupId>org.eluder.juniter</groupId>
    <artifactId>juniter-guice</artifactId>
    <version>1.2.0-SNAPSHOT</version>
</dependency>

Continuous integration

Travis CI builds juniter with Oracle JDK 7 and OpenJDK 6.

Build Status

License

The project juniter is licensed under the MIT license.

Versions

Version
1.1.2
1.1.1
1.1.0
1.0.0