Skip to content

Commit

Permalink
Merge pull request #1956 from Orange-OpenSource/functional-tests
Browse files Browse the repository at this point in the history
Functional tests
  • Loading branch information
Dan Sparacio committed Jun 2, 2017
2 parents 6a7a264 + 858c36d commit 9be2840
Show file tree
Hide file tree
Showing 58 changed files with 1,172 additions and 108 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ module.exports = function (grunt) {
},
mocha_istanbul: {
test: {
src: './test',
src: './test/unit',
options: {
mask: '*.js',
coverageFolder: './reports',
Expand Down Expand Up @@ -291,4 +291,4 @@ module.exports = function (grunt) {
grunt.registerTask('debug', ['clean', 'browserify:all', 'exorcise:all', 'copy:dist']);
grunt.registerTask('lint', ['jshint', 'jscs']);
grunt.registerTask('prepublish', ['githooks', 'dist']);
};
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"grunt-jsdoc": "^0.6.0",
"grunt-mocha-istanbul": "^3.0.1",
"ink-docstrap": "^1.1.1",
"intern": "^3.2.3",
"iron-mocha": "^1.0.3",
"iron-node": "^3.0.15",
"istanbul": "^0.4.1",
Expand Down
3 changes: 3 additions & 0 deletions test/functional/config/applications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
local:'http://localhost/DEV/Orange-OpenSource/dash.js/test/functional/tests.html'
});
20 changes: 20 additions & 0 deletions test/functional/config/browsers/mac.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
define(function () {

var CHROME_CONFIG = {
browserName: 'chrome',
platform: 'MAC'
};

var FIREFOX_CONFIG = {
browserName: 'firefox',
platform: 'MAC'
};

return {
all: [CHROME_CONFIG, FIREFOX_CONFIG],

chrome: [CHROME_CONFIG],

firefox: [FIREFOX_CONFIG]
};
});
37 changes: 37 additions & 0 deletions test/functional/config/browsers/windows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
define(function () {

var CHROME_CONFIG = {
browserName: 'chrome',
platform: 'WINDOWS',
os: 'WINDOWS',
os_version: '10'
};

var IE11_CONFIG = {
browserName: 'internet explorer',
platform: 'WINDOWS'
};

var EDGE_CONFIG = {
browserName: 'MicrosoftEdge',
platform: 'WINDOWS'
};
var FIREFOX_CONFIG = {
browserName: 'firefox',
platform: 'WINDOWS',
os: 'WINDOWS',
os_version: '10'
};

return {
all: [CHROME_CONFIG, IE11_CONFIG, EDGE_CONFIG, FIREFOX_CONFIG],

chrome: [CHROME_CONFIG],

ie: [IE11_CONFIG],

edge: [EDGE_CONFIG],

firefox: [FIREFOX_CONFIG]
};
});
29 changes: 29 additions & 0 deletions test/functional/config/os.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
define(function (require) {

var MAC = {};
var WINDOWS = {};

var getWindowsBrowers = function () {
var browsers = require('./browsers/windows.js');

for (var key in browsers) {
WINDOWS[key] = browsers[key];
}
};

var getMacBrowsers = function () {
var browsers = require('./browsers/mac.js');

for (var key in browsers) {
MAC[key] = browsers[key];
}
};

getWindowsBrowers();
getMacBrowsers();

return {
mac: MAC,
windows: WINDOWS
};
});
18 changes: 18 additions & 0 deletions test/functional/config/selenium.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
define({

local: {
proxyUrl: 'http://127.0.0.1:3555',
proxyPort: 3555,
tunnel: 'NullTunnel',
tunnelOptions: {
hostname: '127.0.0.1',
port: '4444',
verbose: true
},
reporters: ['Runner'],
capabilities: {
'selenium-version': '3.4.0'
},
leaveRemoteOpen:'fail'
}
});
36 changes: 36 additions & 0 deletions test/functional/config/streams.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"DASH_VOD_1": {
"url": "http://dash.edgesuite.net/akamai/bbb_30fps/bbb_30fps.mpd",
"name": "SegmentTemplate/Number, live profile, 250kbps up to 15Mbps@4K.",
"type": "VOD",
"protocol": "DASH"
},

"DASH_VOD_2": {
"url": "http://rdmedia.bbc.co.uk/dash/ondemand/testcard/1/client_manifest-events.mpd",
"name": "SegmentTemplate/Number, live profile",
"type": "VOD",
"protocol": "DASH"
},

"DASH_LIVE_1": {
"url": "http://vm2.dashif.org/livesim/testpic_2s/Manifest.mpd",
"name": "SegmentTemplate without manifest updates (livesim)",
"type": "Live",
"protocol": "DASH"
},

"DASH_LIVE_2": {
"url": "http://vm2.dashif.org/livesim/mup_30/testpic_2s/Manifest.mpd",
"name": "SegmentTemplate with manifest updates every 30s (livesim)",
"type": "Live",
"protocol": "DASH"
},

"MSS_VOD_1": {
"url": "http://2is7server2.rd.francetelecom.com/hasplayer/VOD_1/VOD_1.ism/manifest",
"name": "Prince Of Persia",
"type": "VOD",
"protocol": "MSS"
}
}
39 changes: 39 additions & 0 deletions test/functional/config/testsConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
define(function (require) {

var fs = require('intern/dojo/node!fs');
var streams = JSON.parse(fs.readFileSync('./test/functional/config/streams.json', 'utf8'));

var streamsArray = [];
for (var key in streams) {
streamsArray.push(streams[key]);
}

var _createInstance = function () {
return {
asyncTimeout: 10,

tests: {
default: {
streams: streamsArray
},

seek: {
seekCount: 5
},

pause: {
pauseCount: 2
}
}
};
};

var _getInstance = function () {
if (!this._instance) {
this._instance = _createInstance();
}
return this._instance;
};

return _getInstance();
});
23 changes: 23 additions & 0 deletions test/functional/config/testsSuites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
define(function () {

var PLAY_TESTS = [
'test/functional/tests/play/play',
];

var PAUSE_TESTS = [
'test/functional/tests/play/pause'
];

var SEEK_TESTS = [
'test/functional/tests/play/seek'
];

var ALL_TESTS = PLAY_TESTS.concat(PAUSE_TESTS, SEEK_TESTS);

return {
all: ALL_TESTS,
play: PLAY_TESTS,
pause: PAUSE_TESTS,
seek: SEEK_TESTS
};
});
109 changes: 109 additions & 0 deletions test/functional/docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Functional testing

This README explains how to run functional tests for dash.js project, based on Selenium and the Intern framework.
The tests can be executed using BrowserStack platform, meanwhile it details how to launch the functional tests locally on your desktop, using selenium grid.

## Intern
Proposed functional tests are based upon Intern framework (https://theintern.github.io/).
To install Intern, perform a ```npm install``` command in dash.js root folder.

## Web application for tests
To run the tests you have to serve a web application that is able to run the dash.js player.
This web application must declare the video element and the dash.js MediaPlayer instance, respectively with the ids ```'video'``` and ```'player'```.

## Tests scripts
The folder ```tests``` contains the different scripts for testing each functionnality/scenario.
For example the script ```test/play/play.js``` is testing the scenario for playing a stream.

When writing a functional test, instead of executing application code directly, we do use the Leadfoot Command object, provided by the Intern framework, to automate interactions to test the application (see https://theintern.github.io/leadfoot/module-leadfoot_Command.html).

Also in order to automate and check the tests results we do use the Chai Assertion Library (http://chaijs.com/) which is also bundled with Intern.

All the tests can interact with the video element and the MediaPlayer instance provided by the tested web application with the help of functions declared in ```test/video_functions.js``` and ```test/player_functions.js```

## Selenium and tests configuration
In ```config``` folder, you will multiple configurations files that are used by the ```testCommon.js``` script to run tests:
- ```selenium.js``` provides the configuration for the Selenium nodes configuration. Only 'local' configuration is provided so far
- ```os.js``` and ```browsers/*.js``` provides the available Selenium configurations for executing the tests on the different browsers on different platforms
- ```applications.js``` provides the configuration for some web application that can be used to execute the tests
- ```streams.json``` provides the streams configuration that can be used by the different tests
- ```testsConfig.js``` provides some configuration parameters for each test contained in ```tests``` folder
- ```testsSuites.js``` provides some suites of tests that can be run independently

## Running tests on Windows
#### WebDrivers
In ```tools``` folder, the following web drivers are available:
- Chrome
- Firefox
- Edge
- IE11

#### Launch the tests
1. Start selenium hub. Open a new terminal and launch the command:
```sh
cd test/functional/tools
startHub.bat
```

2. Start selenium node. Open a new terminal and launch the command:
```sh
cd test/functional/tools
startClient.bat
```

3. Start Intern runner. Open a new terminal and launch the command:
```sh
cd test/functional
./runTestsWin.bat
```

This last command contains a script for running tests on all browsers.
The script can be modified and executed (from project root folder) in order to run the tests:
- on specific browsers (see ```config/browsers/windows.js```),
```sh
browser=<browser_names_separated_by_comma>
```
- on a specific testing web application (see ```config/applications.js```)
```sh
app=<app_name_from_config_file> or appurl=<app_url>
```
- only for a specific suite of tests (see ```config/testsSuites.js```)
```sh
tests=<test_suites_names_separated_by_comma>
```

For example:
```sh
node node_modules/intern/runner.js config=test/functional/testsCommon.js os=windows browsers=chrome|firefox appurl=http://... tests=play
```

## Running tests on Mac OSX
#### Chrome
Download latest chrome driver (chromedriver) from https://sites.google.com/a/chromium.org/chromedriver/downloads
Make sure installation path is available in PATH variable.
You can follow this article : http://www.kenst.com/2015/03/installing-chromedriver-on-mac-osx/

#### Firefox
Download last firefox driver (geckodriver) from https://github.com/mozilla/geckodriver/releases
Make sure installation path is available in PATH variable.

#### Launch the tests
1. Start selenium hub. Open a new terminal and launch the command :
```sh
cd test/functional/tools
java -jar selenium-server-standalone-3.4.0.jar -role hub
```

2. Start selenium node. Open a new terminal and launch the command :
```sh
cd test/functional/tools
java -jar selenium-server-standalone-3.4.0.jar -role node
```
3. Start Intern runner. Open a new terminal and launch the command:
```sh
cd test/functional
./runTestsMac.sh
```

As for Windows, the script can be modified to setup the tests.

5 changes: 5 additions & 0 deletions test/functional/runTestsMac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd ../..

node node_modules/intern/runner.js config=test/functional/testsCommon.js os=mac browsers=all app=local

cd test/functional
5 changes: 5 additions & 0 deletions test/functional/runTestsWin.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd ../..

node node_modules/intern/runner.js config=test/functional/testsCommon.js os=windows browsers=all app=local

cd test/functional
Loading

0 comments on commit 9be2840

Please sign in to comment.