-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 69965e6
Showing
122 changed files
with
18,416 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# IntelliJ IDEA | ||
*.iws | ||
*.iml | ||
*.ipr | ||
.idea | ||
|
||
# Eclipse | ||
.classpath | ||
.project | ||
.settings | ||
|
||
node_modules | ||
output | ||
nano.save | ||
npm-debug.log | ||
|
||
e2e-test | ||
|
||
.sonar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"preset": "airbnb", | ||
"maximumLineLength": 140, | ||
"requirePaddingNewLinesBeforeLineComments": { | ||
"allExcept": "firstAfterCurly" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
save-exact=true | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
dist: trusty | ||
sudo: required | ||
|
||
addons: | ||
sonarcloud: | ||
organization: "racodond" | ||
|
||
env: | ||
global: | ||
- secure: "fcQ0jJuCgCi79X69qotQKihZCNXf0KuPvePKyvFdP7T2DlTXY9IdMlc0eqgegH1t4vcF7REYKZew270veyGRtQjcSnQuTV/FkviK2wryRNC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zMCRb0s5K0Xtj/Xd8iDR/+6N52Do0hARd88dsKNRu+A91hWqp95OAgbMReLvKB4eq5/qAtNsXX0/tG65n/o2tibzXVa3yMTaHxU9hDsrPJvxcekfI96ZRkXxhsXpNd942AJpzt4uVWyvKolN1QDBAMpbkYp8GqH+MvCMM+Hh8eQfKc5BaBvvspP7DE=" | ||
|
||
language: node_js | ||
node_js: | ||
- '8' | ||
|
||
jdk: | ||
- oraclejdk8 | ||
|
||
cache: | ||
directories: | ||
- "$HOME/.sonar/cache" | ||
|
||
script: "./travis.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## Contributing | ||
|
||
1. Open a [new issue](https://github.com/racodond/etaf/issues/new) or pick up an [existing one](https://github.com/racodond/etaf/issues) | ||
1. Code, unit tests, document, etc. | ||
1. Commit your changes with message "Fix #X Issue title" | ||
1. Create a PR | ||
1. Check that the builds are green | ||
1. Fix any SonarQube issues that would have pop up during the builds | ||
1. Assign racodond (David RACODON) as reviewers of the PR | ||
1. Once approved, merge the PR (prefer Squash and merge) | ||
|
||
## Building and Testing | ||
* To retrieve dependencies: `npm install --no-optional` | ||
* To run unit tests: `npm run test` | ||
* To run end-to-end tests: `npm run e2e-test`. If you are behind a proxy, uncomment (and update if necessary) line `seleniumInstallArgs: { // proxy: 'http://localhost:3128'`, in `lib/conf/wdio.conf.js`. | ||
* To run end-to-end tests in Docker containers: `npm run e2e-test-docker`. If you are behind a proxy, run `npm run e2e-test-docker -- --proxyPort=XXXX` instead. | ||
|
||
|
||
## Publishing a new version of the npm package | ||
Requirements: | ||
|
||
1. Check that the [latest build on master](https://travis-ci.org/racodond/etaf) is green | ||
2. Check that the [SonarQube quality gate](https://sonarcloud.io/dashboard?id=etaf) is green | ||
|
||
From your IDE: | ||
|
||
2. Checkout a clean `master` branch | ||
3. Update the package version by running the following command replacing `<type>` with either `major`, `minor` or `patch`: | ||
``` | ||
npm version <type> -m "Release version %s" | ||
``` | ||
It upgrades the version in `package.json` and commit the change with "Release version X.X.X" message. | ||
|
||
4. Generate the JSDoc by running `npm run doc` | ||
5. Push the changes in `./docs` to GitHub: `git add docs && git commit -m "Generate documentation for version 2.5.0" && git push origin master` | ||
6. Publish a new release of the npm package by running `npm publish` | ||
|
||
From your browser: | ||
|
||
7. Close the [milestone](https://github.com/racodond/etaf/milestones) | ||
8. Publish a new [new release](https://github.com/racodond/etaf/releases/new) on GitHub: | ||
* Tag version: npm package version | ||
* Release title: short title describing the main change(s) | ||
* Description: a link to the issues of the milestone (https://github.com/racodond/etaf/milestone/X?closed=1) + any other information that would be relevant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
'use strict'; | ||
|
||
module.exports = function (grunt) { | ||
|
||
grunt.initConfig({ | ||
mochaTest: { | ||
test: { | ||
options: { | ||
reporter: 'spec', | ||
require: ['test/unit/test-common'], | ||
}, | ||
src: ['test/unit/**/*.test.js'], | ||
}, | ||
}, | ||
|
||
mocha_istanbul: { | ||
coverage: { | ||
src: ['test/unit/**/*.test.js'], | ||
options: { | ||
coverageFolder: 'output/coverage', | ||
reportFormats: ['html', 'lcovonly'], | ||
root: './lib', | ||
require: ['test/unit/test-common'], | ||
}, | ||
}, | ||
}, | ||
|
||
shell: { | ||
e2eTest: { | ||
command: './test/e2e/run-e2e-test-local.sh', | ||
}, | ||
e2eTestDocker: { | ||
command: proxyPort => './test/e2e/docker-compose-e2e-test.sh ' + proxyPort, | ||
}, | ||
}, | ||
|
||
jsdoc: { | ||
dist: { | ||
src: ['lib/browser-command/*.js', 'lib/helper/helper.js'], | ||
options: { | ||
destination: 'docs', | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
grunt.loadNpmTasks('grunt-mocha-istanbul'); | ||
grunt.loadNpmTasks('grunt-jsdoc'); | ||
grunt.loadNpmTasks('grunt-shell'); | ||
|
||
grunt.registerTask('test', 'Run unit tests', 'mochaTest'); | ||
grunt.registerTask('test-with-coverage', 'Run unit tests with code coverage computation', 'mocha_istanbul'); | ||
grunt.registerTask('doc', 'Generate JSDoc', 'jsdoc'); | ||
grunt.registerTask('e2e-test', 'Run end-to-end tests', 'shell:e2eTest'); | ||
|
||
grunt.registerTask('e2e-test-docker', 'Run end-to-end tests in Docker containers', function () { | ||
let command = 'shell:e2eTestDocker'; | ||
|
||
const proxyPort = grunt.option('proxyPort'); | ||
if (proxyPort) { | ||
command += ':' + proxyPort; | ||
} | ||
|
||
grunt.task.run([command]); | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2017 Nestlé S.A. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
[![npm version](https://badge.fury.io/js/etaf.svg)](https://badge.fury.io/js/etaf) | ||
[![Build Status](https://travis-ci.org/racodond/etaf.svg?branch=master)](https://travis-ci.org/racodond/etaf) | ||
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/5wsjr8by0lqsngw4/branch/master?svg=true)](https://ci.appveyor.com/project/racodond/etaf/branch/master) | ||
|
||
[![Quality Gate status](https://sonarcloud.io/api/project_badges/measure?project=etaf&metric=alert_status)](https://sonarcloud.io/dashboard?id=etaf) | ||
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=etaf&metric=ncloc)](https://sonarcloud.io/dashboard?id=etaf) | ||
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=etaf&metric=coverage)](https://sonarcloud.io/dashboard?id=etaf) | ||
|
||
# Easy Test Automation Framework (ETAF) | ||
|
||
This framework is designed to help you get easily and quickly started with test automation on any project. | ||
It is based on [WebdriverIO](http://webdriver.io/) and [cucumber](https://cucumber.io/) ([cucumberJS](https://github.com/cucumber/cucumber-js) to be exact). | ||
Integrating this module provides a ready-to-go environment to write and execute functional test scenarios. | ||
It includes: | ||
* A template to generate your test automation project so that you don't start from a blank page | ||
* The necessary packages pre-configured to be able to run your scenarios without requiring any other setup. The only requirement is to have a browser on the machine running the tests: either Chrome or Firefox. | ||
* [Guidelines and good practices](https://github.com/racodond/etaf/blob/master/template/doc/Framework.md) to ensure great maintainability of test scenarios | ||
* A decoupled architecture between scenarios and data sets to allow high execution scalability | ||
* Some useful [custom browser commands](http://webdriver.io/guide/usage/customcommands.html) such as `fillInForm` to ease and accelerate test automation writing. See related [JSDoc](https://racodond.github.io/etaf/) for more details. | ||
|
||
This framework is suitable for big solutions that will be covered by an important number of scenarios. | ||
Note that it requires good development skills as well as good knowledge and understanding of JavaScript. | ||
|
||
## Integrating ETAF to Your Project | ||
|
||
### Prerequisites | ||
* Install [npm](https://www.npmjs.com/) and [Node.js](https://nodejs.org) (latest available 8.X.X version) | ||
* Install [npx](https://www.npmjs.com/package/npx): `npm install -g npx` | ||
* Install [Java JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (version 8 or greater) | ||
|
||
### Adding ETAF Package and Configuration to Your Project | ||
1. Create a new folder <AUTOMATED_TESTS> in your project to host your automated tests. | ||
2. Create a new NPM project by executing `npm init`. More information about the different options [here](https://docs.npmjs.com/getting-started/using-a-package.json). | ||
3. Install EAT package by running the following command from <AUTOMATED_TESTS>: `npm install --save etaf`. It creates a `node_modules` directory containing all the dependencies needed to run the project. | ||
4. From <AUTOMATED_TESTS>, run `npx etaf install` to generate the skeleton of your test project. | ||
|
||
### Behind a Proxy | ||
Set the configuration of your proxy by editing the `.npmrc` file in your home directory: | ||
``` | ||
proxy=http://localhost:3128 | ||
https-proxy=http://localhost:3128 | ||
``` | ||
|
||
|
||
## Running Functional Tests | ||
* Run `npx etaf run` to launch the tests as they would be played remotely. | ||
* Run `npx etaf run wdio.local.conf.js` to run the tests with local configuration. | ||
* Run `npx etaf run wdio.debug.conf.js` to run the tests with debug configuration (see Running Tests in Debug Mode section | ||
for mode details). | ||
|
||
Note that the local and debug configurations have to be generated first (see Configuration section). | ||
|
||
### Configuration | ||
* The global configuration is set in the `wdio.conf.js` file, in the root folder of your project. | ||
* The local configuration is set in the `wdio.local.conf.js`. This local configuration can be reset by running | ||
`npx etaf generate-local-conf`. | ||
* The debug configuration is set in the `wdio.debug.conf.js`. This debug configuration can be reset by running | ||
`npm etaf generate-local-conf`. | ||
|
||
### Parameters | ||
To pass parameters to the command, add `--`: `npx etaf run --parameter1=value1` | ||
|
||
#### URL of the Website to Test | ||
Add command line parameter `--baseUrl="https://base.url"` or update the wdio configuration file accordingly. | ||
|
||
#### Locale | ||
Add command line parameter `--locale="en"` or update the wdio configuration file accordingly. | ||
|
||
#### Running a Subset of Tests Using Tags | ||
Add command line parameter `--tagExpression='@tag'`. | ||
|
||
Tags can be combined: | ||
* `--tagExpression='@tag1 or @tag2'` runs test tagged with `@tag1` or `@tag2` | ||
* `--tagExpression='@tag1 and @tag2'` runs test tagged with both `@tag1` and `@tag2` | ||
* `--tagExpression='not @tag1'` runs tests not tagged with `@tag1` | ||
|
||
See [Cucumber Tag Expressions documentation](https://docs.cucumber.io/cucumber/api/#tag-expressions) for more details. | ||
|
||
#### Realm (market, brand, environment, ...) | ||
A realm is a configuration file that defines some wdio properties specific to a realm. A realm can be seen as a market, | ||
a brand, an environment (such as dev or staging), etc. or a combination of them. Realm files are stored in the | ||
`conf/realm` directory. | ||
|
||
Usually realms define at least the following properties: | ||
* `baseUrl`: website to test | ||
* `specs`: list of features to run | ||
|
||
Add command line parameter `--realm="xxx"`. Where `xxx` is the file name in `conf/real` without the `.js` extension. | ||
|
||
For example: | ||
* To run NRT tests from the catalog domain on mywebsite.com: `npx etaf run --baseUrl="https://mywebsite.com" --tagExpression='@nrt and @catalog'` | ||
* To run NRT tests on realm `us-dev`: `npx etaf run --realm="us-dev" --tagExpression='@nrt'` | ||
|
||
|
||
## Running Functional Tests in Debug Mode | ||
For IntelliJ, follow instructions at [Debug with Chrome Debugging Protocol](https://www.jetbrains.com/help/idea/running-and-debugging-node-js.html#ws_node_debug_remote_chrome). | ||
At step #4, run `npx etaf run wdio.debug.conf.js` | ||
|
||
|
||
## Running Unit Tests | ||
* Run `npx etaf test-unit` to run unit tests | ||
* Run `npx etaf test-unit-with-coverage` to run unit tests with code coverage computation | ||
|
||
|
||
## Writing Automated Tests | ||
Read detailed explanations in [Framework.md](https://github.com/racodond/etaf/blob/master/template/doc/Framework.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: "{build}" | ||
|
||
environment: | ||
nodejs_version: 8 | ||
|
||
platform: | ||
- x86 | ||
- x64 | ||
|
||
install: | ||
- ps: Install-Product node $env:nodejs_version | ||
- node --version | ||
- npm --version | ||
- npm install | ||
|
||
test_script: | ||
- npm run test | ||
- npm run test-with-coverage | ||
- npm run doc | ||
|
||
build: off |
Oops, something went wrong.