2012-02-09 42 views
1

我认为目前没有很多Chutzpah用户,但希望我会在这里找到一些。使用Chutzpah的Visual Studio扩展索引超出范围错误

我正在制作一个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错误?还是在那里有一个我还没找到的bug修复?

任何提示的赞赏,但请不要评论我的一般测试策略,因为我很清楚这些缺陷。这仅仅是为了举例目的:)

回答

1

这个问题是一个问题的方式Chutzpah确定行号。我刚部署了版本1.3.2(CodePlex,Vs GalleryNuGet),这将允许Chutzpah处理这个错误,以便您仍然可以获得测试结果。但是,在上面的代码中,行号检测将无法正常工作。我已经提交了一个单独的issue来解决这个问题。