Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Java BDD framework with Data Driven-Development? [closed]

I am looking for Java Behaviour-driven development test frameworks that integrates well with Data-driven development (parametrized values). I started using easyb, but it seems not really data-driven friendly. Looking at the documentation JBehave looks a more consolidated framework, has anyone used one of hose framework with Selenium (Maven project) with CSV or JSON files as feeds.

Cheers,

like image 976
sebarmeli Avatar asked Jan 28 '26 07:01

sebarmeli


1 Answers

You can use JGiven together with JUnit and the JUnit-DataProvider. You can then write tests like this one:

@Test
@DataProvider( {
    "0, 0, Error: No coffees left",
    "0, 1, Error: No coffees left",
    "1, 0, Error: Insufficient money",
    "0, 5, Error: No coffees left",
    "1, 5, Enjoy your coffee!",
} )
public void correct_messages_are_shown( int coffeesLeft, int numberOfCoins, String message ) {
    given().a_coffee_machine()
        .and().there_are_$_coffees_left_in_the_machine( coffeesLeft );

    when().I_insert_$_one_euro_coins( numberOfCoins )
        .and().I_press_the_coffee_button();

    then().the_message_$_is_shown( message );
}

The full example can be found on GitHub

Disclaimer: I am the author of JGiven

like image 120
Jan Schaefer Avatar answered Jan 30 '26 20:01

Jan Schaefer