如何判断哪些testing花费最多的时间在茉莉花?

我注意到整套Jasminetesting开始花费更多的时间,但是我不确定哪些testing会导致延迟。 有没有办法find这一点,而不是单独运行每个testing?

基本的ConsoleReporter只报告所有testing的时间,但是如果你看看它的源代码 ,你会发现很容易修改每个规格的时间。 基本上你需要做的就是当函数reportSpecStarting (就在一个spec开始运行之前)被调用时logging一个spec开始的时间,并且当函数reportSpecStarting (刚刚在一个spec完成运行之后)被输出。

所以如果你用这个修改了ConsoleReporter ,它会输出你每个规格的名称和它们的经过时间:

 this.reportSpecStarting = function() { this.specStartingTime = this.now(); }; this.reportSpecResults = function(spec) { var results = spec.results(); print(results.description + " "); if (results.skipped) { yellowStar(); } else if (results.passed()) { greenDot(); } else { redF(); } print(" (" + (this.now() - this.specStartingTime) + "ms)"); newline(); }; 

那么使用Jasmines HTMLReporter呢? (向下) http://pivotal.github.com/jasmine/

嗯..也许你可以循环它,使每个文件被单独执行? (不是最好的答案:() http://elegantcode.com/2011/03/07/taking-baby-steps-with-node-js-bdd-style-unit-tests-with-jasmine-node-sprinkled-有几家,应该/