Javascript CasperJS-如何跳到下一个测试套件?

Javascript CasperJS-如何跳到下一个测试套件?,javascript,testing,casperjs,ui-automation,Javascript,Testing,Casperjs,Ui Automation,我引用这句话: 在执行本例中的第一个测试套件时,如何跳到测试套件?我想跳到Casperjs.org是上面示例中排名第一的测试套件吗 或者换句话说,是否有方法跳到下一个可用的casper.test.begin块 我已经试过了,但给出的文档没有给我如何实现上述目标的想法。这在CasperJS提供的公共API中是不可能的 话虽如此,CasperJS的tester模块以一种简单的方式管理测试用例。所以你只要打个电话就可以了 test.queue.shift(); 要删除下一个测试,请开始块或 删除任何

我引用这句话:

在执行本例中的第一个测试套件时,如何跳到测试套件?我想跳到Casperjs.org是上面示例中排名第一的测试套件吗

或者换句话说,是否有方法跳到下一个可用的casper.test.begin块


我已经试过了,但给出的文档没有给我如何实现上述目标的想法。

这在CasperJS提供的公共API中是不可能的

话虽如此,CasperJS的tester模块以一种简单的方式管理测试用例。所以你只要打个电话就可以了

test.queue.shift();
要删除下一个测试,请开始块或

删除任何未来的块。请注意,如果测试用例本身不是异步的,这将不适用于。这也是我在概念验证中使用casper.start.then.run组合的原因

警告:这没有文档记录,可能会在将来的版本中更改

概念证明:

casper.test.begin("test 1", function(test){
    casper.start().then(function(){
        test.assertTrue(true);
    }).run(function(){
        test.done();
    });
});

casper.test.begin("test 2", function(test){
    casper.start().then(function(){
        //test.queue.splice(0, 1);
        test.queue.shift();
        test.assertTrue(true);
    }).run(function(){
        test.done();
    });
});

casper.test.begin("test 3 (invisible)", function(test){
    casper.start().then(function(){
        test.assertTrue(true);
    }).run(function(){
        test.done();
    });
});

casper.test.begin("test 4 (visible)", function(test){
    casper.start().then(function(){
        test.assertTrue(true);
    }).run(function(){
        test.done();
    });
});
输出:

Test file: skip_begin_block.js # test 1 PASS test 1 (NaN test) PASS Subject is strictly true # test 2 PASS test 2 (NaN test) PASS Subject is strictly true # test 4 (visible) PASS test 4 (visible) (NaN test) PASS Subject is strictly true PASS 3 tests executed in 0.226s, 3 passed, 0 failed, 0 dubious, 0 skipped.
我使用了以下解决方案:

casper.start(url, function () {
  this.thenBypassIf(my_condition, 1);
});
casper.then(function() {
  // This step will be ignored if the above "my_condition" is true.
});

你的意思是跳过上一个casper.test.begin块的下一个casper.test.begin块?是的。跳转到下一个可用的casper.test.begin块我的回答有助于解决问题吗?有什么问题吗?@ArtjomB。我还在考虑这个问题,还没有时间尝试你的答案。我会检查一下,然后再回来 Test file: skip_begin_block.js # test 1 PASS test 1 (NaN test) PASS Subject is strictly true # test 2 PASS test 2 (NaN test) PASS Subject is strictly true # test 4 (visible) PASS test 4 (visible) (NaN test) PASS Subject is strictly true PASS 3 tests executed in 0.226s, 3 passed, 0 failed, 0 dubious, 0 skipped.
casper.start(url, function () {
  this.thenBypassIf(my_condition, 1);
});
casper.then(function() {
  // This step will be ignored if the above "my_condition" is true.
});