Introduction BBDStack - bcgov/common-service-showcase GitHub Wiki
Welcome to BDDStack, this is an automated framework that supports BDD and is based on Geb and Spock.
What is BDD?
Behavioral Driven Development (BDD) is a software development approach that has evolved from TDD (Test Driven Development). It differs by being written in a shared language, which improves communication between tech and non-tech teams and stakeholders. In both development approaches, tests are written ahead of the code, but in BDD, tests are more user-focused and based on the system’s behavior.
Test cases are written in a common language used by the stakeholders such as, for example, English. This access to clearer, low-jargon communication is probably the biggest advantage to using BDD, making it possible for collaboration between the technical and non-technical teams to run with improved efficiency.
Characteristics of BDD
As described above, the advantage to BDD test cases being written in a common language is that details of how the application behaves can be easily understood by all. For example, test cases can be written using real-time examples of the actual requirements, to explain the behavior of the system. BDDStack implements this common language as the "spine" of the automated tests.
Essentials to have in place before implementing BDD
- Requirements should be converted into user stories that can define concrete examples.
- Each example should be a valid user scenario, rather than a mere test case.
- An understanding of the ‘role-feature-reason’ matrix and the ‘given-when-then’ formula.
- An awareness of the need to write ‘the specification of the behavior of a class’ rather than ‘the unit test of a class’.
The ‘Given-When-Then’ formula BDD example
This is the proposed template for writing BDD test cases for a user story, which can be defined as:
Given a certain scenario
When an action takes place
Then this should be the outcome.
A practical example would be:-
Given the User has not entered any data on the form
When they click the submit button
Then proper validation messages should be show.
Role-Feature-Reason matrix
This template is also used in BDD, in order to aid user story creation. This template is defined as:-
As a
I want
So that
An example of such a user story would be: As a mine manager, I want to report our COVID readiness, so that we can be inspected on compliance.
BDDStack - the Framework
The solution consists of a stack of technologies, hence the name BDDStack. The stack looks as follows from the top down:
- Spock http://spockframework.org/ - Enables the BDD features
- Geb http://www.gebish.org/manual/current - Geb is a developer focused tool for automating the interaction between web browsers and web content. It uses the dynamic language features of Groovy to provide a powerful content definition DSL (for modelling content for reuse) and key concepts from jQuery to provide a powerful content inspection and traversal API (for finding and interacting with content).
- Selenium https://github.com/SeleniumHQ/selenium/wiki - We use the Selenium WebDriver, a collection of language specific bindings to drive a browser - the way it is meant to be driven.
- Groovy http://groovy-lang.org/ - Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the Java platform
- Gradle https://gradle.org/ - Package for deployment of BDDStack on any platform (that supports Java).
This core framework has then been enhanced by adding features like:
- Spock Reports https://github.com/renatoathaydes/spock-reports
- BrowserStack Integration https://www.browserstack.com
- Guidance for running as part of CI, Local and on BrowserStack
- Docker Images