Setting up Continuous Integration of Protractor using Jenkins

后端 未结 5 1270
走了就别回头了
走了就别回头了 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:47

    I created a small bash script to do this.

    # start selenium
    ./node_modules/protractor/bin/webdriver-manager start > /dev/null 2>&1 &
    
    # wait until selenium is up
    while ! curl http://localhost:4444/wd/hub/status &>/dev/null; do :; done
    
    # run the build
    grunt cibuild --force
    
    # stop selenium
    curl -s -L http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer > /dev/null 2>&1
    

    This script is invoked from a free-style project in jenkins (Build > Execute shell)

    enter image description here

    Then the test result report is generated by reading the protractor test results. Hence, you have to produce junit reports from protractor, (look here) :

    onPrepare: function() {
      // The require statement must be down here, since jasmine-reporters
      // needs jasmine to be in the global and protractor does not guarantee
      // this until inside the onPrepare function.
      require('jasmine-reporters');
      jasmine.getEnv().addReporter(
        new jasmine.JUnitXmlReporter('xmloutput', true, true));
    },
    

    To make the report visible in jenkins i add a post build action in the job: Publish JUnit test result report:

    enter image description here

提交回复
热议问题