Check out the documentation (soon!)
Behavior-Driven Development (BDD) is an agile software development methodology that encourages collaboration between developers, QA, and non-technical or business participants in a software project. It extends Test-Driven Development (TDD) by writing test cases in a natural language that non-programmers can read.
BDD focuses on:
- Defining behaviour in a shared language - Creating a ubiquitous language that all team members can understand
- Documenting examples - Using concrete examples to illustrate the expected behaviour
- Automating validation - Converting examples into automated tests
The core of BDD is the ability to express tests in a language that both technical and non-technical stakeholders can understand, while still being executable as automated tests.
BDD offers numerous advantages for software development teams:
-
Improved Communication - BDD bridges the gap between technical and non-technical team members by using a common language to describe system behaviour.
-
Living Documentation - Tests serve as documentation that is always up-to-date because it's executable and verified with each build.
-
Focus on User Value - By describing behaviour from the user's perspective, teams stay focused on delivering features that provide real value.
-
Reduced Rework - Clear specifications from the beginning help avoid misunderstandings that lead to rework.
-
Higher Quality Code - Writing tests before implementation leads to better design and more maintainable code.
-
Faster Feedback - Automated tests provide immediate feedback on whether the system behaves as expected.
Kensa is a modern BDD testing framework for Kotlin and Java that simplifies behaviour-driven development. Unlike traditional BDD frameworks that require separate text files for specifications, Kensa allows you to write your tests directly in your code using a natural, fluent syntax.
- Native Language Support - Write tests in Kotlin or Java without the need for external DSL files
- Expressive Syntax - Use your own fluent, readable syntax following the Given-When-Then pattern
- Rich HTML Output - Generate interactive documentation illustrating the functionality under test
- Sequence Diagrams - Automatically generate sequence diagrams to visualize interactions between components
- Framework Integration - Seamlessly integrate with JUnit5. TestNG and Kotest coming soon!
- Flexible Assertions - Use your preferred assertion library (Hamcrest, HamKrest, Kotest, AssertJ)
- Variable/Scenario Tracking - Choose to capture and display the values of fields and scenario values directly in your test output
Traditional BDD frameworks like Cucumber require you to:
- Write feature files in Gherkin syntax
- Implement step definitions that map to the Gherkin statements
- Maintain the mapping between the two
Kensa simplifies this process by:
- Writing tests directly in your code using a natural, fluent syntax
- Automatically generating documentation from your code
- Eliminating the need to maintain separate feature files
This approach reduces overhead while still providing the benefits of BDD, making it easier to adopt and maintain over time.
In the following sections, we'll show you how to get started with Kensa and demonstrate its capabilities through practical examples.