Giter Site home page Giter Site logo

timothyearley / jgiven Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tng/jgiven

0.0 1.0 0.0 6.09 MB

Behavior-Driven Development in plain Java

Home Page: http://jgiven.org

License: Apache License 2.0

Shell 1.44% Java 97.27% Scala 0.27% Groovy 0.80% Kotlin 0.18% CSS 0.01% HTML 0.03%

jgiven's Introduction

Build Status Coverage Status Apache License 2.0 Maven Central Join the chat at https://gitter.im/TNG/JGiven Javadocs Open Source Helpers

JGiven

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.

Why another BDD tool?

Behavior-Driven Development (BDD) is a development method where business analysts, developers, and testers describe the behavior of a software product in a common language and notation. Behavior is typically described in terms of scenarios, which are written in the Given-When-Then notation. The common language and notation is one cornerstone of BDD. The other cornerstone is that the defined scenarios are executable, form a comprehensive test suite, and a living documentation for the software product.

In classical BDD tools for Java like JBehave or Cucumber scenarios are written in plain text files. This allows non-developers to write scenarios, because no programming knowledge is required. To make scenarios executable, developers write so-called step-implementations. To bind plain text to step implementations regular expressions are used. For developers maintaining these executable scenarios has a high overhead that is not required if tests would be directly written in a programming language.

Beside the classical BDD tools there are a number of tools for Java to write BDD tests in a programming language like Groovy (easyb) or Scala (ScalaTest). To our knowledge, however, there is no BDD tool where scenarios can be written in plain Java.

Finally, there are specification testing frameworks like Spock (Groovy) or LambdaBehave which are very developer-centric and good for unit-testing, but the generated reports are not in Given-When-Then form and are not easily readable by non-developers.

BDD with JGiven

  • Scenarios are written in standard Java code using a fluent, domain-specific API (no extra language like Scala or Groovy needed, no IDE plugin needed)
  • Java method names and parameters are parsed during test execution (no extra annotations needed)
  • Scenarios are executed by either JUnit or TestNG (no extra test runner needed)
  • Scenarios consist of so-called stages, which share state by injection, providing a modular way of writing Scenarios.
  • JGiven generates scenario reports for business owners and domain experts

Example

@Test
public void 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_pancake();
}

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 pancake

In addition, you can generate an HTML Report.

Getting Started

  1. Start by reading the documentation section on JGiven's website.
  2. See the talk on JGiven held on the TNG Big TechDay

License

JGiven is published under the Apache License 2.0, see https://www.apache.org/licenses/LICENSE-2.0 for details.

Contributing

See CONTRIBUTING

jgiven's People

Contributors

l-1squared avatar renovate[bot] avatar renovate-bot avatar janschaefer avatar johthor avatar cirquit avatar andru47 avatar jsalinaspolo avatar fudler avatar aaschmid avatar airblader avatar ahus1 avatar originx avatar actions-user avatar catchin avatar jangalinski avatar leimer avatar triplenail avatar wolfs avatar sheamunion avatar codecholeric avatar rubbiroid avatar laurinvesely avatar cptblackadder avatar wuan avatar achimh3011 avatar hankem avatar albertofaci avatar dependabot[bot] avatar nikowitt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.