Some cases for unit testing with Java 8:
1. One can use lambda expressions in test code to implement lightweight stubs. if the collaborator to be stubbed is a functional interface. I found a neat description of this approach in "Java 8 Lambdas" book (
http://www.amazon.com/Java-Lambdas-Pragmatic-Functional-Programming/dp/1449370772/ref=sr_1_1?s=books&ie=UTF8&qid=1404769897)
2. Lambda Expressions can help in testing exceptions in
JUnit and therefore can easily replace libraries like catch-exception or even plain JUnit @Rule.
Having simple functional interface like this:
We can achieve a syntax like below:
Please have a look at blog post that describes this approach in more detail:
http://blog.codeleak.pl/2014/07/junit-testing-exception-with-java-8-and-lambda-expressions.html