Behavior-Driven Development in Plain Java

JGiven is a developer-friendly and pragmatic BDD tool for Java. Developers write scenarios in plain Java using a fluent, domain-specific API, JGiven generates reports that are readable by domain experts.


- Version 0.11.3 Released


public void a_pancake_can_be_fried_out_of_an_egg_milk_and_flour() {
        and().the_ingredient( "flour" );



The above test can be executed like any JUnit test. During the execution, JSON files are generated that can then be used afterwards to generated test reports. By default, a plain text report is shown in the console, which would look as follows:

Scenario: a pancake can be fried out of an egg milk and flour

  Given an egg
    And some milk
    And the ingredient flour
   When the cook mangles everything to a dough
    And the cook fries the dough in a pan
   Then the resulting meal is a pan cake

Further examples can be found in the jgiven-examples module of JGiven.

HTML Report

Besides the plain text report, an HTML report can be generated. An example of such a report is JGiven’s own report:

JGiven HTML5 report of JGiven

The source code of the corresponding JGiven tests are in the jgiven-tests module of the JGiven project.

Key facts

  • Scenarios are written in plain Java with a fluent Java API - Neither text files, nor Groovy is needed
  • Method names are parsed at runtime and define the scenario text - No duplicate text in annotations is needed
  • Scenarios are executed by either JUnit or TestNG - No extra test runner is needed, thus JGiven works with all existing IDEs and build tools for Java out-of-the-box
  • Scenarios are composed of multiple, reusable so-called Stage classes - No more test code duplication
  • Scenarios and steps can be parameterized for writing data-driven tests
  • JGiven generates HTML reports that can be read and understand by domain experts and serve as a living documentation

Talk on JGiven at BigTechday 8

Jan Schäfer gave a talk on JGiven at the BigTechday 8. It explains the rationale behind JGiven and gives an introduction into the main features of JGiven.

Talk on JGiven at Devoxx France 2016 (in French)

Marie-Laure Thuret (@mlthuret) and Clément Héliou (@c_heliou) did a live coding session with JGiven at Devoxx France 2016.