简体   繁体   中英

How to send an email when protractor e2e test case fails?

I am writing protractor e2e test cases. While running the test cases, if any test case fails it should send an email. How to do that?

Thanks in advance.

Following Leo's comments.

This is not something you need to solve on the protractor level. protractor itself is basically a browser automation testing framework which mimics user action to test your web site.

The usual way to report about the test failures by email is to do it on a continuous integration server, like jenkins or bamboo . The idea is to use JUnitXmlReporter reporter from jasmine-reporters to generate the Junit XML report which jenkins or bamboo know how to read and analyze. Then, report the test results by email.

Call JUnitXmlReporter in your onprepare() function in the protractor config :

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));
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM