Setting up Continuous Integration of Protractor using Jenkins

后端 未结 5 1269
走了就别回头了
走了就别回头了 2020-12-04 12:26

I am writing automation test scripts using Protractor and now I need to set up the CI for this using Jenkins.

Tasks it needs to perform are:

  1. Starting t
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 12:49

    You can use Gulp which is far simpler.

    After installing gulp in Jenkins System , you may install the npm dependencies(npm install) & run gulp tasks directly as windows batch command in Jenkins as below:

    In the background to make selenium server up and running and providing various other parameters , you may use packages like 'gulp-angular-protractor' in the gulpfile.js as below:

    gulpfile.js

    'use strict';
    
     var gulp = require('gulp'),
     gulpProtractorAngular = require('gulp-angular-protractor'),
     gulpStart = gulp.Gulp.prototype.start,
     currentStartTaskName;
    
     gulp.Gulp.prototype.start = function (task) {
        currentStartTaskName = task;
        gulpStart.apply(this, arguments);
    };
    function executeWebTests(suiteName, appName) {
        return gulp.src([])
            .pipe(gulpProtractorAngular({
                'configFile': './conf.js',
                'debug': false,
                'autoStartStopServer': true,
                args: [
                    '--suite', suiteName,
                    '--capabilities.browserName', 'chrome',
                    '--params.APPNAME', appName,
                    '--params.SUITENAME', currentStartTaskName,
                    '--capabilities.platformName', 'Windows'],
                keepAlive: false
            }))
            .on('error', function (e) {
                console.log('Ended with below ERROR::',e);
                process.exit(1);
            })
            .on('end', function () {
                console.log('Test complete');
                process.exit();
            });
    }
    
    gulp.task('RegressionSuiteTask', function () {
        executeWebTests('regressionTests,','Application_Name');
    });
    

    conf.js

     suites: {
              regressionTests: ['testCases/**/*.js']//will run all specs in subfolders 
             },
    

提交回复
热议问题