allow running of just ios or just android functional tests

This commit is contained in:
Jonathan Lipps
2013-03-05 10:46:53 -08:00
parent 582fd5d94a
commit 51afa762ba
3 changed files with 33 additions and 20 deletions

View File

@@ -32,20 +32,20 @@ module.exports = function(grunt) {
, appiumutils: ['test/functional/appium/appiumutils.js']
}
, mochaTestWithServer: {
TestApp: {
TestApp: ['ios', {
functional: ['test/functional/testapp/*.js']
, server: ['test/functional/appium/appium.js'
, 'test/functional/appium/jsonwp.js']
}
, UICatalog: {
}]
, UICatalog: ['ios', {
functional: ['test/functional/uicatalog/*.js']
}
, WebViewApp: {
}]
, WebViewApp: ['ios', {
functional: ['test/functional/webview/*.js']
}
, ApiDemos: {
}]
, ApiDemos: ['android', {
functional: ['test/functional/apidemos/*.js']
}
}]
}
, mochaTestConfig: {
options: {
@@ -59,10 +59,16 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('functional', "Run functional tests", function(log) {
runTestsWithServer(grunt, null, 'functional', log === "log", this.async());
runTestsWithServer(grunt, null, 'functional', null, log === "log", this.async());
});
grunt.registerTask('servertest', "Run functional server tests", function(log) {
runTestsWithServer(grunt, 'TestApp', 'server', log === "log", this.async());
runTestsWithServer(grunt, 'TestApp', 'server', null, log === "log", this.async());
});
grunt.registerTask('android', "Run functional android tests", function(log) {
runTestsWithServer(grunt, null, 'functional', 'android', log === "log", this.async());
});
grunt.registerTask('ios', "Run functional ios tests", function(log) {
runTestsWithServer(grunt, null, 'functional', 'ios', log === "log", this.async());
});
grunt.registerTask('test', ['jshint', 'buildApp:TestApp', 'buildApp:UICatalog', 'buildAndroidApp:ApiDemos', 'unit', 'appiumutils', 'functional', 'servertest']);
grunt.registerTask('unit', 'mochaTest:unit');

View File

@@ -6,13 +6,15 @@ kinds of appium dev tasks. Here's what you can do:
|Task|Description|
|----|-----------|
|grunt appium|Start an appium server|
|grunt downloadApp|Download the UICatalog app from Apple|
|grunt lint|Run JSLint|
|grunt test|Run all the tests|
|grunt functional|Run the functional test suite|
|grunt unit|Run unit tests|
|grunt appium|Start an appium server|
|grunt functional|Run the entire functional test suite|
|grunt android|Run the functional test suite for android|
|grunt ios|Run the functional test suite for ios|
|grunt unit|Run the unit tests|
|grunt mobileSafari|Start an Appium server with mobile Safari loaded|
|grunt downloadApp|Download the UICatalog app from Apple|
|grunt buildApp:&lt;AppName&gt;:&lt;SDK&gt;|Build an iOS app for the iPhone Simulator. Expects there to be a .app at `sample-code/apps/<AppName>/build/Release-iphonesimulator/<AppName>.app`. Default SDK is 'iphonesimulator6.0'|
|grunt signApp:&lt;certName&gt;|Signs the test app with an absolute path to an iOS dev certificate|
|grunt authorize|Authorize your simulator to run without prompting|

View File

@@ -38,13 +38,13 @@ module.exports.startAppium = function(appName, verbose, readyCb, doneCb) {
);
};
module.exports.runTestsWithServer = function(grunt, appName, testType, verbose, cb) {
module.exports.runTestsWithServer = function(grunt, appName, testType, deviceType, verbose, cb) {
if (typeof verbose === "undefined") {
verbose = false;
}
var exitCode = null;
var appServer = module.exports.startAppium(appName, verbose, function() {
module.exports.runMochaTests(grunt, appName, testType, function(code) {
module.exports.runMochaTests(grunt, appName, testType, deviceType, function(code) {
appServer.close();
exitCode = code;
});
@@ -54,7 +54,7 @@ module.exports.runTestsWithServer = function(grunt, appName, testType, verbose,
});
};
module.exports.runMochaTests = function(grunt, appName, testType, cb) {
module.exports.runMochaTests = function(grunt, appName, testType, deviceType, cb) {
// load the options if they are specified
var options = grunt.config(['mochaTestConfig', testType, 'options']);
@@ -69,9 +69,14 @@ module.exports.runMochaTests = function(grunt, appName, testType, cb) {
}
var args = ['-t', options.timeout, '-R', options.reporter, '--colors'];
var fileConfig = grunt.config(['mochaTestWithServer']);
_.each(fileConfig, function(config, configApp) {
if (!appName || appName === configApp) {
_.each(config, function(testFiles, testKey) {
var configAppDevice, nameOk, deviceOk, configAppTests;
_.each(fileConfig, function(config, configAppName) {
configAppDevice = config[0];
configAppTests = config[1];
nameOk = !appName || appName === configAppName;
deviceOk = !deviceType || deviceType === configAppDevice;
if (nameOk && deviceOk) {
_.each(configAppTests, function(testFiles, testKey) {
if (testType == "*" || testType == testKey) {
_.each(testFiles, function(file) {
_.each(grunt.file.expand(file), function(file) {