【发布时间】:2017-09-26 19:17:12
【问题描述】:
我最近安装了jasmine-spec-reporter 包,以便在执行测试套件期间生成更详细和有用的日志记录。
我希望能够为失败的测试用例记录 expected 和 actual 值,并且想知道我是否需要以 expect(someCondition).toEqual(true); 的形式明确声明以便我看到这些值。
例如,我有如下函数:
it('should log in', function(done) {
var customerNameElement;
customerNameElement = element.all(by.xpath('some_xpath')).first();
core.infoMessage(browser, JSON.stringify(params, undefined, 4));
login.login(browser, undefined, undefined, getWaitTime())
.then(function() {
return browser.wait(protractor.ExpectedConditions.and(
function() { return core.isUnobscured(browser, customerNameElement);
}, protractor.ExpectedConditions.elementToBeClickable(customerNameElement)), getWaitTime());
})
.catch(fail)
.then(done);
});
我仍然可以将故障记录到控制台,但不是以我想要的形式。 jasmine-spec-reporter 是否处理此问题,还是我必须在每个测试用例中添加上面的语句?
另外,.catch() 中的 fail 关键字是否有任何我可以利用的属性?它来自:
// Jasmine 2.5.2 的类型定义 // 项目:http://jasmine.github.io/
谢谢
【问题讨论】:
-
是否已经为失败的测试用例记录了预期值和实际值?即
expected true to be false...expected 1 to equal 2等。 -
@Gunderson,这是我返回的一个示例:
× should display the text element - Failed: No element found using locator: By(xpath, some_xpath)但话又说回来,xpath 可能没有预期值。想法? (这是另一个测试用例,不是上面列出的) -
嗯,这是一个 ElementFinder 错误,它描述了您面临的问题(该元素不存在,因此它无法执行您尝试执行的任何操作)。我不明白你到底想要什么来代替那个错误?
-
我认为某些
it函数不会产生expected和actual值,例如上面的那个。对于xpath错误,我同意你的观点,抛出的错误是应该产生的。有没有办法将Expected 0 to be 1更改为Expected false to be true?
标签: jasmine protractor e2e-testing