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 ...