Re: JUnit-BDD

Cédric Beust ♔ <[email protected]> Sat, 19 Apr 2014 10:56:52 -0700
Newsgroups gmane.comp.java.junit.user
Message-ID <CAOphgJD4jvfKrh1g_YEMcru3Hi=xt3BryuTytTkdX+4T_P0wcA@mail.gmail.com>
On Fri, Apr 18, 2014 at 10:41 AM, David Saff <[email protected]> wrote:


>
> I think that Java 8 lambdas open up a lot of opportunities to accomplish
> JUnit's goals in completely different ways.  I've been exploring with one
> approach myself on and off.  For one thing, to date, JUnit has relied on
> specially-named or annotated methods to accomplish the goal of succinctly
> associating a name with a block of code.  In Java 8, one can just do:
>
> addTest("Some test name", () -> {
>    // some code here
> })
>
I don't see a lot of added value for this over

@Test(description = "Some test name")public void shouldDoSomething) { ... }

Actually, you lose a lot of expressivity that annotations give you for
free, such as adding configuration parameters to your test (e.g. specifying
concurrency settings, inheriting annotations from a base class, etc...).

I've tried to find ways to leverage lambdas as well for testing and I've
come up completely empty so far.
-- 
Cedric