Initialization of the steps library is triggered via the command:
npx cds-add-cucumber
It will perform the following operations:
default:
requireModule:
- "@cap-js-community/cds-cucumber"
{
"cucumberautocomplete.steps": [
"test/features/step_definitions/*.js",
"node_modules/@cap-js-community/cds-cucumber/lib/steps/*.js"
],
"cucumberautocomplete.strictGherkinCompletion": true
}
In addition to the provided steps you can add your own steps in your repository. By default they should be located in the following folder:
test/features/step_definitions
Additional information about using local SAP UI5 build can be found here.
In order to get support (like code completion) for VSCode while writing your specifications, you can install one of the following plugins:
Cucumber for Visual Studio Code (CucumberOpen)
Default configuration in file:
.vscode/settings.json
{
"cucumber.features": [
"test/features/**/*.feature"
],
"cucumber.glue": [
"test/features/step_definitions/**/*.js",
"node_modules/@cap-js-community/cds-cucumber/lib/steps/*.js"
]
}
Cucumber (Gherkin) Full Support
Default configuration in file:
.vscode/settings.json
{
"cucumberautocomplete.steps": [
"test/features/step_definitions/*.js",
"node_modules/@cap-js-community/cds-cucumber/lib/steps/*.js"
],
"cucumberautocomplete.strictGherkinCompletion": true
}
Information can be found here.
Information can be found here.
The selenium-webdriver nodejs module is used to control the browser and it requires a webdriver. The version of the webdriver should match the version of the web browser. The node module chromedriver is used to download the latest webdriver version automatically. Both modules are listed in the dependencies of this module.
Most systems are configured to update the browser automatically which requires also an update of the webdriver. You can update the chrome webdriver to the latest version with the following command:
npm install chromedriver --chromedriver_version=LATEST
In cases where the browser is not installed or can not be started (CI), you can run selenium and the corresponding browser in docker as follows:
docker run -d --network host selenium/standalone-chrome
By default the selenium/standalone-chrome image opens the port 4444 to access the webdriver.
SELENIUM_REMOTE_URL="http://127.0.0.1:4444/wd/hub" npx cucumber-js test
Server-side code-covarage is available using the native V8 code-coverage module c8 and it can be activated via the environment variable CDS_CUCUMBER_CODECOV.
npm add @cap-js-community/odata-v2-adapter
Given we require communication protocol "odata-v2"
CDS_CUCUMBER_COMMUNICATION_PROTOCOL="odata-v2"
annotate AdminService with
@protocol: [
{ kind: 'odata-v2', path: '/odata/v2/admin' },
{ kind: 'odata-v4', path: '/odata/v4/admin' }
];