30 Mar 2014, 19:05
Generic-user-small

Philippe Jean (1 post)

Hi,

I started to read this great book and I’m in love with functional programming. “Functional programming in scala” and “Learn You a Haskell for great good!” are two other books which waiting on my nightstand. But it’s not the topic here :)

I’m a bit stuck on how to test lambda expressions and I seen only manual test until now (chapter 3). I would like to use BDD framework in ideal world. What framework would you recommend ? I don’t know how test a lambda expression which is private static final for example.

Thanks

31 Mar 2014, 20:24
Venkatsubramaniam_pragsmall

Venkat Subramaniam (84 posts)

Hi Philippe,

There are two answers to this question.

  1. We can use JUnit to test the code that uses lambda expressions. Furthermore, lambda expressions can be tested separately as well (by invoking them from tests much like how we can invoke them from code that uses them).

  2. There is one sticky area, however. Functions that take in lambda expressions can evaluate them lazily instead of calling them right away. This means that if we invoke a function, the function may return and decide to call the function later on (possibly from another thread). We need to see some tools support in this area before we can easily test them. For instance, nodeunit has a nice feature that will tell us a test is complete only when the callback invokes a done() method. We would need support like that in Java based testing tools.

Regards,

Venkat

  You must be logged in to comment