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.
Feb 24, 2023 - Version 1.2.5 Released
Oct 24, 2022 - Version 1.2.4 Released
Oct 14, 2022 - Version 1.2.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 generate 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
Tools in Action Session on JGiven at Devoxx Belgium 2016
Jan Schäfer gave a Tools in Action session at Devoxx Belgium 2016. It mainly consists of a live demo showing how to refactor an existing JUnit test to use 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.
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.