I think you are asking about how lambdas can simplify your test code. (rather than how to test lambas).
I think most tests will be too simple to benefit. But tests with more complex assertions can be simplified. For example, I often write a helper assertion method that looks like:
Yes, I could use a comparator, but then I'd be writing it just for this method. With lambas, I could express this whole method in one line.
Teresa Sparkman wrote:We have a java-based test framework and use testNG. How can lambdas be used to simplify code testing?
Hi Teresa,
I think the biggest benefit isn't their direct usage in test code, although there is a good example elsewhere in this thread of that happening, its actually in making it easier to abstract over different behaviours. Being able to pass in some behaviour as a parameter makes it a lot easier to write code which is testable. In the same way that depending on any abstraction makes it easier to write code that's testable.
regards,
Richard
Post by:autobot
Squanch that. And squanch this tiny ad:
a bit of art, as a gift, that will fit in a stocking