【问题标题】:What does the "test.begin()" function mean in CasperJS?CasperJS 中的“test.begin()”函数是什么意思?
【发布时间】:2015-01-12 15:11:38
【问题描述】:

我不太了解函数test.begin(String description, Number planned, Function suite)。参数Number planed是干什么用的?

【问题讨论】:

    标签: testing methods parameters casperjs


    【解决方案1】:

    Number planned 是您希望测试的asserts 的数量。这完全是optional 并且可以被认为是您的测试脚本实际上已经完全完成的完整性检查。

    docs states:-

    计划参数在给定测试脚本的情况下特别有用 被突然打断,让你没有明显的方式知道它,并且 错误的成功状态。

    一个例子:-

    casper.test.begin('when testing foo', 3, function() {
        test.assertEquals(1 === 1, '1 equals 1');
        test.assertEquals(5 === 5, '5 equals 5');
        test.done();
    });
    

    这个测试实际上会失败,因为我已经定义了3 planned asserts,但只有 2 个成功(因为只有 2 个断言)。

    【讨论】:

      猜你喜欢
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      • 2011-01-21
      • 2014-01-29
      • 2019-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多