Skip to content

BDD from anywhere unit/integration tests or simply any java code

Notifications You must be signed in to change notification settings

codehackerr/simple-bdd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-bdd

Status

Build Status

A lightweight BDD framework for your unit tests. This implementation follows a gherkin style syntax. The idea is to add expressiveness of a natural language to your unit tests.

A planned extension of this framework is to promote self contained test methods and test steps. The benefit is neat and independent tests. The idea is to pass system under test and dependencies as step parameters and not exposing them to outside scope.

Usage:

@RunWith(Suite.class)
@Suite.SuiteClasses(TestClass.class)
public class TestSuite {

    @BeforeClass
    public static void beforeSuite() {
        SimpleBDD.setReporter(Reporter.Console);
    }
}
    
public class TestClass {

    @Test
    public void string_building() {

        String hello = "hello";
        String world = "world";
        StringBuilder helloWorld = new StringBuilder();
        scenario("append strings")
            .given("Two non empty strings", () -> {

                assert hello.length() != 0;
                assert world.length() != 0;

            }).when("Appended", () -> {

                helloWorld.append(hello).append(world);

            }).then("Gives a bigger string!", () -> {

                assertThat(helloWorld.toString(), is("helloworld"));

            });
    }
}

Console Report:

===========================
Scenario: append strings
Given: Two non empty strings- OK
When: Appended- OK
Then: Gives a bigger string!- OK
====== END SCENARIO =======

About

BDD from anywhere unit/integration tests or simply any java code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages