JUnit Lambda Extensions

JUnit extensions that make use of Java 8 lambdas.

License

License

MIT
Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.github.marschall
ArtifactId

ArtifactId

junit-lambda
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

JUnit Lambda Extensions
JUnit extensions that make use of Java 8 lambdas.
Project URL

Project URL

https://github.com/marschall/junit-lambda
Source Code Management

Source Code Management

https://github.com/marschall/junit-lambda

Download junit-lambda

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.marschall/junit-lambda/ -->
<dependency>
    <groupId>com.github.marschall</groupId>
    <artifactId>junit-lambda</artifactId>
    <version>0.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.marschall/junit-lambda/
implementation 'com.github.marschall:junit-lambda:0.3.0'
// https://jarcasting.com/artifacts/com.github.marschall/junit-lambda/
implementation ("com.github.marschall:junit-lambda:0.3.0")
'com.github.marschall:junit-lambda:jar:0.3.0'
<dependency org="com.github.marschall" name="junit-lambda" rev="0.3.0">
  <artifact name="junit-lambda" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.marschall', module='junit-lambda', version='0.3.0')
)
libraryDependencies += "com.github.marschall" % "junit-lambda" % "0.3.0"
[com.github.marschall/junit-lambda "0.3.0"]

Dependencies

provided (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

JUnit λ Build Status Maven Central

JUnit extensions built on Java 8 lambdas. Helps to test exceptions and can be used instead of the following pattern:

try {
    Long.parseLong("foo");
    fail("'foo' should not be a valid long");
} catch (NumberFormatException e) {
    // should reach here
}

You can either use #assertRaises

import static com.github.marschall.junitlambda.LambdaAssert.assertRaises;
import org.junit.Test;

public final class JunitLambdaTest {
    @Test
    public void testNumberFormatException() {
        assertRaises(() -> Long.parseLong("foo"), NumberFormatException.class);
    }
}

or the Hamcrest matcher #throwsException

import static com.github.marschall.junitlambda.ThrowsException.throwsException;
import org.junit.Test;

public final class JunitLambdaTest {
    @Test
    public void testNumberFormatException() {
        assertThat(() -> Long.parseLong("foo"), throwsException(NumberFormatException.class));
    }
}
<dependency>
    <groupId>com.github.marschall</groupId>
    <artifactId>junit-lambda</artifactId>
    <version>0.3.0</version>
    <scope>test</scope>
</dependency>

The code is under MIT license.

Versions

Version
0.3.0
0.2.0
0.1.0