Releasing the Gen monad

Some time ago I wrote a piece about generating randomized instances of domain objects for unit and integration testing using a functional approach. Looking back at my past projects, I almost always used this approach to simplify existing and newly written tests in the codebases that I was working on. Of course, the implementation matured over the years as well. What started off as a very simplistic @FunctionalInterface became a well-tested Java-based implementation of the Gen monad. Given that I use this small piece of code so often, I decided to release the Gen monad to the public.

more ...

Property-Based Testing in Java 8

In the last article we learned how to generate objects with Java 8 in a functional way and implemented a small API based around the Gen monad. Although already powerful on its own, generators really shine when we use them in combination with property-based testing. A property-based test verifies a statement about the output of your code based on some given input. The same statement - or property - is verified for many different possible inputs to find one that falsifies the property. This article builds upon the implementation of Gen and discusses a simple API that enables us to write property-based tests.

more ...

Functional Generators in Java 8

I recently had the chance to toy around with property-based testing. Property-based tests verify statements about the output of your code based on some input, where the same statement is verified for many different possible (admissible and inadmissible) inputs. Such tests rely heavily upon randomly generated objects and values. Even if you do not fully commit to property-based testing, having abstractions for generating random objects and values from your domain can simplify testing a lot. This article shows how to build a simple generator-based approach that plays well along with property-based testing and can simplify your test cases tremendously.

more ...


Buchrezension zu Functional Programming in Java 8

Mit Version 8 erreichen Lambda Expressions endlich Java und gehören in naher Zukunft zum Standard-Repertoire eines jeden Java-Entwicklers. Doch wie schlägt man am besten die Brücke von Java 7 zu Java 8? Nahezu zeitgleich mit dem Release von Java 8 ist das neue Buch Functional Programming in Java von Venkat Subramaniam erschienen. Das Buch hat den Anspruch, genau diese Lücke zu schließen und insbesondere Leser mit wenig bis keiner Erfahrung in funktionaler Programmierung effektiv mit den Möglichkeiten der neuen Lambda-Funktionen und der Streams-API vertraut zu machen.

more ...