Overview
On this page
Cucumber
Cucumber is a tool that allows functional tests with different language (Java, Javascript, Rubi, Kotlin).
Usage
Inside your folder tests/automation/
, you will have two files minimum:
dictionary.js
in/steps-definitions
- X step definition files (can be in folders) in root folder
Dictionary
In dictionary, you will have all path to access to screens, routes, views and some elements you need to launch your tests. All chosen names are defined between developers and testers. Here an example of a simple dictionary :
module.exports = {
screens: {
"my first screen with a specific page": {
route: "myFirstRoute",
screenName: "myFirstScreen",
options: {
page: "myFirstPage"
}
},
"my second screen": {
route: "mySecondRoute",
screenName: "mySecondScreen"
}
},
views: {
"my view": "path.to.myView",
"my view first button": "path.to.myView.and.firstButton"
},
events: {
"my event": "name.of.event"
}
}
An initial route must be declared in this dictionary to reset some information of ui (item focused in a view for example) and you must add this initial route in screens like this example :
module.exports = {
initialRoute: "myInitialRoute",
screens: {
"myInitialRoute": {
route: "myInitialRoute",
options: {
content: {},
boolean: true
}
}
}
};
Step definitions
In step definition files, you must import your dictionary and @dana/cucumber-steps
(defines generic steps). Depending on your needs, you will add some specifics steps in this file. Here an example of a simple stepDefs file :
const dictionary = require("./steps-definitions/dictionary"),
{Given, When, Then} = require('cucumber');
// /!\ IMPORTANT - LOAD Generic step definitions /!\
require('@dana/cucumber-steps')(dictionary);
// ///////////////////////
// // SPECIFIC STEPS
// ///////////////////////
// my first specific step
When("step specific action", function () {
// do some action
});
// my first specific step
Then("step specific assert", function () {
// do some assertion(s)
});
Example:
cucumber-js --require ./tests/automation/step-definitions/initSpec.js --require ./tests/automation/step-definitions/**/*.js ./tests/automation/features/**/*.feature --exit
In this example, we initialize some steps to launch functional tests. The last path is to define features files.
Caution
Don’t forget to finish your script with –exit to kill process in terminal when tests are finished or crashed.
Cli
Wiztivi cli offers some commands to shorten commands to run functional tests.
wtv test:cucumber
allows you to run all functional test files located inside ./tests/automation/features/**/*.feature
.
wtv test:cucumber:single <PATH_TO_FILE>
allows you to specify a file or a glob pattern file path to execute. You can execute the following commands for example:
wtv test:cucumber:single ./tests/automation/features/Go_to_fip.feature
wtv test:cucumber:single ./tests/automation/features/myModule/**/*.feature