我认为目前没有很多 Chutzpah 用户,但希望我能在这里找到一些。
我正在制作 Pavlov 的演示,以便将其与传统的 QUnit 测试进行对比,并向我的团队展示 BDD 的优势。一路上我偶然发现了 Chutzpah,并认为集成到我的项目中会非常酷。
当我右键单击并在浏览器中运行测试时,它们都可以正常工作,但是如果我右键单击并在 VS 中运行测试,则会出现以下错误:
------ Test started: File: C:\Users\U0120711\Documents\Visual Studio 2010\Projects\Behave\StaticContent\tests\Calculator\calculatorTest.js ------
Chutzpah Error Occured:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at Chutzpah.TestResultsBuilder.Build(BrowserTestFileResult browserTestFileResult)
at Chutzpah.TestRunner.RunTestsFromHtmlFile(String headlessBrowserPath, TestOptions options, TestContext testContext, List`1 testResults, ITestMethodRunnerCallback callback)
at Chutzpah.TestRunner.RunTests(IEnumerable`1 testPaths, TestOptions options, ITestMethodRunnerCallback callback)
While Running:C:\Users\U0120711\Documents\Visual Studio 2010\Projects\Behave\StaticContent\tests\Calculator\calculatorTest.js
========== Total Tests: 0 passed, 0 failed, 0 total ==========
这是我的测试:
巴甫洛夫规格:
/// <reference path="../../js/External/jQuery/jquery-1.7.1.js" />
/// <reference path="../../js/External/qunit/qunit.js" />
/// <reference path="../../js/External/pavlov/pavlov.js" />
/// <reference path="../../js/Calculator/Calculator.js" />
pavlov.specify("The behavior of a calculator", function () {
describe("Calculator", function () {
var calculator;
before(function () {
calculator = new Calculator();
});
given([2, 0], [3, 0], [4, 0]).
it("returns zero when multiplying by zero", function (x, y) {
assert(0).equals(calculator.multiply(x, y));
});
given([2, 1], [3, 1], [4, 1]).
it("returns the multiplicand when multiplying by one", function (x, y) {
assert(x).equals(calculator.multiply(x, y));
});
});
});
QUnit测试:
/// <reference path="../../js/External/jQuery/jquery-1.7.1.js" />
/// <reference path="../../js/External/qunit/qunit.js" />
/// <reference path="../../js/Calculator/Calculator.js" />
var calculator;
module("Calculator", {
setup: function () {
calculator = new Calculator();
}
});
$.each([[2, 0], [3, 0], [4, 0]], function (index, pair) {
test("given " + pair[0] + "," + pair[1] + ", returns zero when multiplying by zero", function () {
equal(0, calculator.multiply(pair[0], pair[1]));
});
});
$.each([[2, 1], [3, 1], [4, 1]], function (index, pair) {
test("given " + pair[0] + "," + pair[1] + ", returns the multiplicand when multiplying by one", function () {
equal(pair[0], calculator.multiply(pair[0], pair[1]));
});
});
我在测试中正在做的事情可能会导致 VS 错误吗?或者是否有一个我还没有找到的错误修复?
感谢任何提示,但请不要评论我的一般测试策略,因为我很清楚这些缺陷。这仅用于示例目的:)