speech bubbles saying 'Given...When...Then'

Narrative

A framework for building behaviour-driven tests in fluent Java

Narrative gives you the tools to write readable behaviour-driven tests in Java, like this:

1. Describe the desired behaviour in fluent Java:

@Test public void adds_two_numbers() { Given.the( operator).was_able_to( press('2')) .was_able_to( press('+')) .was_able_to( press('2')); When.the( operator).attempts_to( press('=')); Then.the( operator).expects_that( the_displayed_value(), is("4")); }

2. Define one or more Actors and Actions for those Actors to carry out, making your acceptance-test code compile

3. Run your acceptance-test and watch it fail

4. Use test-driven development to implement the behaviour described

5. Run your test again and watch it pass

6. Repeat steps 1-5

Resources

Why Narrative?

Acknowledgements

A project of youDevise. We're hiring!

Inspired by JNarrate, a RiverGlide idea.