简体   繁体   English

量角器e2e测试用例失败时如何发送电子邮件?

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

I am writing protractor e2e test cases. 我正在写量角器e2e测试用例。 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. 按照Leo的评论。

This is not something you need to solve on the protractor level. 这不是您需要在protractor级别上解决的问题。 protractor itself is basically a browser automation testing framework which mimics user action to test your web site. protractor本身基本上是一个浏览器自动化测试框架,模仿用户操作来测试您的网站。

The usual way to report about the test failures by email is to do it on a continuous integration server, like jenkins or bamboo . 通过电子邮件报告测试失败的常用方法是在持续集成服务器上执行此操作,如jenkinsbamboo 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. 我们的想法是使用jasmine-reporters JUnitXmlReporter报告生成Junit XML报告, jenkinsbamboo知道如何阅读和分析。 Then, report the test results by email. 然后,通过电子邮件报告测试结果。

Call JUnitXmlReporter in your onprepare() function in the protractor config : 量角器配置中的onprepare()函数中调用JUnitXmlReporter

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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