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.
Mar 20, 2016 - Version 0.11.3 Released
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.
Besides the plain text report, an HTML report can be generated. An example of such a report is JGiven’s own report:
The source code of the corresponding JGiven tests are in the jgiven-tests module of the JGiven project.
- 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.