質問

I think there aren't a lot of Chutzpah users out there currently, but hopefully I will find some on here.

I am working up a demo of Pavlov so I can contrast it to traditional QUnit tests and show my team the advantages of BDD. I stumbled over Chutzpah along the way and thought it would be really cool to integrate into my project.

When I right click and run the tests in my browser, they both work fine, but if I right click and run the tests in VS, I get this error:

------ 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 ==========

Here are my tests:

Pavlov spec:

/// <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 test:

/// <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]));
    });
});

Is there something I'm doing in my tests that could be causing the VS error? Or is there a bug fix out there somewhere that I haven't found yet?

Any tips are appreciated, but please refrain from commenting on my general testing strategy, as I'm well aware of the flaws. It's only for example purposes :)

役に立ちましたか?

解決

This issue is a bug with the way Chutzpah determines line numbers. I just deployed version 1.3.2 (CodePlex, Vs Gallery and NuGet) which will allow Chutzpah to handle this error so that you still get test results. However, in the code above the line number detection will not work correctly. I have filed a separate issue for fixing this.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top