6 July 2014

Lambda Behave 0.2 Released

tl;dr Lambda Behave 0.2 adds a host of improvements including automatic testcase generation.

What is Lambda Behave?

If you're a Java developer and you've seen the fluent, modern specification frameworks available in other programming languages such as spock or jasmine then Lambda Behave is for you. Its overall goal is to make testing a more pleasant experience than it currently is with junit, specifically to:

Here's an example specification to give an example of what Lambda Behave looks like in action:

public class StackSpec {{

    Stack stack = new Stack();

    describe("a stack", it -> {



        it.should("be empty when created", expect -> {

What's new in the 0.2 release?

The biggest new feature is automatic testcase generation, similar to the way quick check or scala check works. The Fluent API for this is similar to data driven specifications allows for control over the way that the values are generated and how many need to be generated. Here is an example of how to show that reversing a String twice returns the same String using randomly generated test case values.

  .toShow("reversing a String twice returns the original String", (expect, str) -> {
      String same = new StringBuilder(str).reverse().reverse().toString();

All generated specifications follow this common pattern where;

In addition 0.2 also bans multiple specifications with the same name in order to make integration with other tools easier and not confuse end users. It fixes a couple of bugs, most importantly that stack traces being were being incorrectly reported in errors. The fluent expectations API has also been significantly extended with more overloads, including support for arrays and exceptions.

Moving Forward

I'm currently looking forward to 0.3 and trying to figure out which features to prioritize and implement. If you have any particular issue that you feel is a priority to you then just comment on it. Contributions via pull request and feedback are also most welcome.

A Quick Plug

If you've been interested in this Lambda Behave blog post then you're probably also interested in Java 8! I've written a book and am teaching a training course to help get Java developers up to speed with Java 8 quickly.

Read More: Too Fast, Too Megamorphic: what influences method call performance in Java?