fuz*_*zzi 5 javascript selenium automated-tests typescript protractor
目前,我有一些我只想在某些条件下执行的测试用例。
it ('user is able to log in', function() {
if(siteAllowsLogin) {
.....
}
Run Code Online (Sandbox Code Playgroud)
使用上述语法会导致 sitesNotAllowingLogin 通过此测试。我知道有一个解决方案可以将测试标记为 PENDING,但我宁愿测试不显示,如果它不适用。
如果可能,我还想将逻辑保留在测试用例中。因此,将 if 块保留在测试用例中。
关于如何在不满足条件的情况下跳过此测试的任何建议,以便它不会在结果中显示为 PENDING 或 PASSED。
帮助将不胜感激。
如果提供的谓词/状态为真,您可以使用ignore
前面的函数来抑制测试:
var ignore = function(exp){return{it:((typeof exp==='function')?exp():exp)?function(){}:it}};
describe('Suite 1', function() {
it("test a", function() {
expect(1).toEqual(1);
});
ignore(true).it("test b", function() {
expect(1).toEqual(1);
});
ignore(skip).it("test c", function() {
expect(1).toEqual(1);
});
function skip(){
return true;
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1934 次 |
最近记录: |