diff --git a/Gruntfile.js b/Gruntfile.js index 3d40758d0..5cbeaf1cf 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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'); diff --git a/docs/grunt.md b/docs/grunt.md index bdbea81a6..3cf09927a 100644 --- a/docs/grunt.md +++ b/docs/grunt.md @@ -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:<AppName>:<SDK>|Build an iOS app for the iPhone Simulator. Expects there to be a .app at `sample-code/apps//build/Release-iphonesimulator/.app`. Default SDK is 'iphonesimulator6.0'| |grunt signApp:<certName>|Signs the test app with an absolute path to an iOS dev certificate| |grunt authorize|Authorize your simulator to run without prompting| diff --git a/grunt-helpers.js b/grunt-helpers.js index 0bde1bd7e..d021ff133 100644 --- a/grunt-helpers.js +++ b/grunt-helpers.js @@ -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) {