[英]Is there a way to get the count for the number of tests in a jasmine describe block?
Is there any way to get the number of tests in a jasmine describe block? 有没有办法在茉莉花描述块中获得测试数量? I am trying to get the number of tests in a describe block to make sure we have tests for all the pubic interface points.
我试图在describe块中获取测试数量,以确保我们对所有公共接口点进行测试。
Assuming you can actually modify the tests yourself and you're not trying to find them completely from the outside..... 假设您可以自己修改测试,而不是试图从外部完全找到它们.....
Just use this
! 只是用
this
!
describe("Testing Suite", function(){
var numOfTests = this.children.size;
console.log(numOfTests);
it("should do something", function(){
//do something
})
it("should do something", function(){
//do something else
})
})
Here, numOfTests
gets the children(tests) of the block, and obviously calling .size
of it will get the number of tests. 在这里,
numOfTests
获取块的儿童(测试),显然调用.size
它会得到测试的次数。
For the sake of listing more ways to accomplish this I will post my own method for accessing the count of the tests inside the describe block. 为了列出更多方法来完成这个,我将发布我自己的方法来访问describe块中的测试计数。
var publicAPI = describe('Public Interface', function () {
/* Methods */
it('should expose/define a initialize method', function () {
expect(controller.initialize).toBeDefined();
});
});
console.log(publicAPI.specs_.length); //this is the count
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.