Fra*_*Boy 9 jasmine protractor
我目前正在编写测试量角器,我想知道是否有可能在beforeEach失败后立即取消测试执行(并返回一些有用的消息,如"前提条件失败:无法登录用户").即我在beforeEach中有一些帮助方法,用于登录用户然后进行一些设置.
beforeEach:
1) login user
2) set some user properties
Run Code Online (Sandbox Code Playgroud)
显然,如果第一步失败,执行第二步没有任何意义(实际上它非常有害,因为用户被锁定并不好).我试图在第一步添加"期望",但第二步仍然执行 - >新鲜的想法.
严格回答你的问题,没有外部依赖:
beforeEach(function() {
// 1) login user
expect(1).toBe(1);
// This works on Jasmine 1.3.1
if (this.results_.failedCount > 0) {
// Hack: Quit by filtering upcoming tests
this.env.specFilter = function(spec) {
return false;
};
} else {
// 2) set some user properties
expect(2).toBe(2);
}
});
it('does your thing (always runs, even on prior failure)', function() {
// Below conditional only necessary in this first it() block
if (this.results_.failedCount === 0) {
expect(3).toBe(3);
}
});
it('does more things (does not run on prior failure)', function() {
expect(4).toBe(4);
});
Run Code Online (Sandbox Code Playgroud)
因此,如果1失败,2,3,4,N将不会按您的预期运行。
还有jasmine-bail-fast但我不确定它在每个场景之前会如何表现。
| 归档时间: |
|
| 查看次数: |
4582 次 |
| 最近记录: |