We need to manage our tests a hierarchical way. This is necessary to keep a proper check on the coverage of any feature. We should have a separate feature for every page in our application. Lets take an example to understand the feature coverage more clearly.
Lets assume that we have an website to manage some employees of a company and there are following modules:
- Admin Account
1.1. Add Employee
1.2. Edit Employee
1.3. Delete Employee
We need the test coverage for above modules. So the we can manage these modules in our tests by having some directory and sub-directory. Each directory will be reflecting a module or tab of the website.
Test coverage for above modules can be covered by having following setup
- To cover "Add Employee" under the "Admin Account" module, set the hierarchy as shown below
Admin (directory 1) > Employees (directory 1.1)> Add Employees (directory 1.1.a) > addEmployeeDetails.feature(your test file name)
In the file add the path "Admin : Employees : Add Employees : Add Employee Details" as a feature description on the top of the file.
- To cover "Edit Employee" under the "Admin Account" module, set the hierarchy as shown below
Admin (directory 1) > Employees (directory 1.1)> Edit Employees (directory 1.1.b) > editEmployeeDetails.java(your test file name)
In the file add the path "Admin : Employees : Edit Employees : Edit Employee Details" as a feature description on the top of the file.
- To cover "Delete Employee" under the "Admin Account" module, set the hierarchy as shown below
Admin (directory 1) > Employees (directory 1.1)> Delete Employees (directory 1.1.c) > deleteEmployeeDetails.java(your test file name)
In the file add the path "Admin : Employees : Delete Employees : Delete Employee Details" as a feature description on the top of the file.
Here, we have added the path of the file in comments of every file. This will help you to locate your files easily. Splitting your website in above mentioned hierarchy will tell help you keep a track that which module of your website has been covered with BDD tests.
For example, lets cover some scenario for "Add Employee" under the "Admin Account" module.
In addEmployeeDetails.feature file
Feature: Admin : Employees : Add Employees : Add Employee Details
In order to verify new employees can be added in the system
As an administrative user
I want to be able to add new employees in the system
Notes:
- Verify that validation messages are shown if invalid characters are used in add new employee form
- Verify that new employee is added in the system if valid information is given
Scenario: Verify that validation messages is shown if all fields are left blank
Given Admin is on "Add New Employee" page
When Admin clicks "Submit" button leaving all fields blank
Then Admin gets validation message that says "Fields can't be blank"
Scenario: Verify that validation messages are shown if special characters are used in date of birth field
Given Admin is on "Add New Employee" page
When Admin fills "$%^*&^%$#" in "Birth Date" field
And Admin clicks "Submit" button after entering valid data in rest of the fields
Then Admin gets validation message that says "Invalid birth date"
Scenario: Verify that employee is registered if valid information is filled
Given Admin is on "Add New Employee" page
When Admin fills "Test Employee" in "Name" field
And Admin fills "12-05-1985" in "Birth Date" field
And Admin selects "India" from "Country" drop down
And Admin clicks "Submit" button
Then Admin gets message that says "Test Employee is added successfully"
So, In the above feature file, we have a section named Notes, under which we write description of all the test cases for which coverage is required.
Thus the feature file should consists of scenarios that fulfills the Notes. This way you can check the coverage for all the tests.
Feature coverage largely depends on what the web page consist of. As you don't have Product owners who define user stories, your QA team needs to decide which scenarios should be covered by BDD tests. Generally, they should add scenarios which covers the feature spec documents.