Initial proposal for integration tests
Change-Id: I512b5c9474f80fd690fdea9d926d15b8146144e4
This commit is contained in:
parent
9ff3916e32
commit
97fe898d8e
23
Gruntfile.js
23
Gruntfile.js
@ -389,6 +389,7 @@ module.exports = function (grunt) {
|
|||||||
server: {
|
server: {
|
||||||
url: 'http://localhost:9000'
|
url: 'http://localhost:9000'
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -508,9 +509,6 @@ module.exports = function (grunt) {
|
|||||||
karma: {
|
karma: {
|
||||||
unit: {
|
unit: {
|
||||||
configFile: './karma-unit.conf.js'
|
configFile: './karma-unit.conf.js'
|
||||||
},
|
|
||||||
integration: {
|
|
||||||
configFile: './karma-integration.conf.js'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -543,8 +541,14 @@ module.exports = function (grunt) {
|
|||||||
args: {
|
args: {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dist: {}
|
dist: {},
|
||||||
|
integration: {
|
||||||
|
options: {
|
||||||
|
configFile: './protractor-integration.conf.js'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -617,7 +621,7 @@ module.exports = function (grunt) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* grunt test:integration
|
* grunt test:unit
|
||||||
*
|
*
|
||||||
* This command will create a clean build against which our unit
|
* This command will create a clean build against which our unit
|
||||||
* tests will be run. For more information, please see
|
* tests will be run. For more information, please see
|
||||||
@ -635,15 +639,14 @@ module.exports = function (grunt) {
|
|||||||
* grunt test:integration
|
* grunt test:integration
|
||||||
*
|
*
|
||||||
* This command will create a clean build against which our integration
|
* This command will create a clean build against which our integration
|
||||||
* tests will be run. For more information, please see
|
* tests will be run.
|
||||||
* karma-integration.conf.js
|
|
||||||
*/
|
*/
|
||||||
grunt.registerTask('test:integration', [
|
grunt.registerTask('test:integration', [
|
||||||
'clean',
|
'clean',
|
||||||
'compile',
|
'compile',
|
||||||
'useminPrepare',
|
'configureProxies:test',
|
||||||
'concat',
|
'connect:test',
|
||||||
'karma:integration'
|
'protractor:integration'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License. You may obtain
|
|
||||||
* a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = function (config) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
config.set({
|
|
||||||
|
|
||||||
port: 9877,
|
|
||||||
|
|
||||||
basePath: '',
|
|
||||||
|
|
||||||
frameworks: ['jasmine'],
|
|
||||||
|
|
||||||
plugins: [
|
|
||||||
'karma-coverage',
|
|
||||||
'karma-jasmine',
|
|
||||||
'karma-html-reporter',
|
|
||||||
'karma-phantomjs-launcher',
|
|
||||||
'karma-chrome-launcher',
|
|
||||||
'karma-firefox-launcher'
|
|
||||||
],
|
|
||||||
|
|
||||||
files: [
|
|
||||||
'./dist/js/libs.js',
|
|
||||||
'./bower_components/angular-mocks/angular-mocks.js',
|
|
||||||
'./dist/js/storyboard.js',
|
|
||||||
'./dist/js/templates.js',
|
|
||||||
'./test/unit/**/*.js'
|
|
||||||
],
|
|
||||||
|
|
||||||
exclude: [
|
|
||||||
],
|
|
||||||
|
|
||||||
singleRun: true,
|
|
||||||
|
|
||||||
reporters: ['dots', 'progress', 'coverage', 'html'],
|
|
||||||
|
|
||||||
colors: false,
|
|
||||||
|
|
||||||
browsers: [ 'PhantomJS', 'Firefox' ],
|
|
||||||
|
|
||||||
preprocessors: {
|
|
||||||
'./dist/js/storyboard.js': ['coverage']
|
|
||||||
},
|
|
||||||
|
|
||||||
coverageReporter: {
|
|
||||||
type: 'html',
|
|
||||||
dir: './cover/integration/'
|
|
||||||
},
|
|
||||||
|
|
||||||
htmlReporter: {
|
|
||||||
outputDir: './reports/integration',
|
|
||||||
templatePath: './node_modules' +
|
|
||||||
'/karma-html-reporter/jasmine_template.html'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
107
protractor-integration.conf.js
Normal file
107
protractor-integration.conf.js
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License. You may obtain
|
||||||
|
* a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// A reference configuration file.
|
||||||
|
exports.config = {
|
||||||
|
seleniumServerJar: './node_modules/selenium-standalone/' +
|
||||||
|
'.selenium/2.43.1/server.jar',
|
||||||
|
chromeDriver: './node_modules/selenium-standalone/' +
|
||||||
|
'.selenium/2.43.1/chromedriver',
|
||||||
|
|
||||||
|
chromeOnly: false,
|
||||||
|
// Additional command line options to pass to selenium. For example,
|
||||||
|
// if you need to change the browser timeout, use
|
||||||
|
// seleniumArgs: ['-browserTimeout=60'],
|
||||||
|
seleniumArgs: [],
|
||||||
|
|
||||||
|
// The timeout for each script run on the browser. This should be longer
|
||||||
|
// than the maximum time your application needs to stabilize between tasks.
|
||||||
|
allScriptsTimeout: 11000,
|
||||||
|
|
||||||
|
// ----- What tests to run -----
|
||||||
|
//
|
||||||
|
// Spec patterns are relative to the location of this config.
|
||||||
|
specs: [
|
||||||
|
'./test/integration/**/*.js'
|
||||||
|
],
|
||||||
|
|
||||||
|
// ----- Capabilities to be passed to the webdriver instance ----
|
||||||
|
//
|
||||||
|
// For a full list of available capabilities, see
|
||||||
|
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
|
||||||
|
capabilities: {
|
||||||
|
'browserName': 'chrome',
|
||||||
|
'chromeOptions': {
|
||||||
|
args: ['--test-type']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ----- More information for your tests ----
|
||||||
|
//
|
||||||
|
// A base URL for your application under test. Calls to protractor.get()
|
||||||
|
// with relative paths will be prepended with this.
|
||||||
|
baseUrl: 'http://localhost:9005',
|
||||||
|
|
||||||
|
// Selector for the element housing the angular app - this defaults to
|
||||||
|
// body, but is necessary if ng-app is on a descendant of <body>
|
||||||
|
rootElement: 'html',
|
||||||
|
|
||||||
|
// A callback function called once protractor is ready and available, and
|
||||||
|
// before the specs are executed
|
||||||
|
// You can specify a file containing code to run by setting onPrepare to
|
||||||
|
// the filename string.
|
||||||
|
onPrepare: function () {
|
||||||
|
'use strict';
|
||||||
|
// At this point, global 'protractor' object will be set up, and jasmine
|
||||||
|
// will be available. For example, you can add a Jasmine reporter with:
|
||||||
|
// jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
|
||||||
|
// 'outputdir/', true, true));
|
||||||
|
},
|
||||||
|
|
||||||
|
// The params object will be passed directly to the protractor instance,
|
||||||
|
// and can be accessed from your test. It is an arbitrary object and can
|
||||||
|
// contain anything you may need in your test.
|
||||||
|
// This can be changed via the command line as:
|
||||||
|
// --params.login.user 'Joe'
|
||||||
|
params: {
|
||||||
|
hostname: 'http://localhost:9005/',
|
||||||
|
login: {
|
||||||
|
user: 'Jane',
|
||||||
|
password: '1234'
|
||||||
|
},
|
||||||
|
buildUrl: function (fragment) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
return this.hostname + '#!' + fragment;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ----- Options to be passed to minijasminenode -----
|
||||||
|
//
|
||||||
|
// See the full list at https://github.com/juliemr/minijasminenode
|
||||||
|
jasmineNodeOpts: {
|
||||||
|
// onComplete will be called just before the driver quits.
|
||||||
|
onComplete: null,
|
||||||
|
// If true, display spec names.
|
||||||
|
isVerbose: false,
|
||||||
|
// If true, print colors to the terminal.
|
||||||
|
showColors: false,
|
||||||
|
// If true, include stack traces in failures.
|
||||||
|
includeStackTrace: true,
|
||||||
|
// Default time to wait in ms before a test fails.
|
||||||
|
defaultTimeoutInterval: 30000
|
||||||
|
}
|
||||||
|
};
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License. You may obtain
|
|
||||||
* a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
describe('sb.services', function () {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var module;
|
|
||||||
var dependencies = [];
|
|
||||||
|
|
||||||
var hasModule = function (moduleName) {
|
|
||||||
return dependencies.indexOf(moduleName) >= 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
// Get module
|
|
||||||
module = angular.module('sb.services');
|
|
||||||
dependencies = module.requires;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should exist', function () {
|
|
||||||
expect(module).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load cookies module', function () {
|
|
||||||
expect(hasModule('ngCookies')).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
34
test/integration/services/projects/module.js
Normal file
34
test/integration/services/projects/module.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License. You may obtain
|
||||||
|
* a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
var request = require('request');
|
||||||
|
var protractor = require('protractor');
|
||||||
|
|
||||||
|
describe('projects integration tests', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
it('should return empty projects list', function () {
|
||||||
|
browser.execute(function() {
|
||||||
|
var deferred = protractor.promise.defer();
|
||||||
|
request.get('http://localhost:9005/api/v1/projects',
|
||||||
|
function(e, c, body) {
|
||||||
|
deferred.fulfill(body);
|
||||||
|
});
|
||||||
|
return deferred.promise;
|
||||||
|
}).then(function(results) {
|
||||||
|
expect(results).toEqual('[]');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user