簡體   English   中英

有沒有辦法計算jasmine describe塊中的測試數量?

[英]Is there a way to get the count for the number of tests in a jasmine describe block?

有沒有辦法在茉莉花描述塊中獲得測試數量? 我試圖在describe塊中獲取測試數量,以確保我們對所有公共接口點進行測試。

假設您可以自己修改測試,而不是試圖從外部完全找到它們.....

只是用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
    })
})

在這里, numOfTests獲取塊的兒童(測試),顯然調用.size它會得到測試的次數。

為了列出更多方法來完成這個,我將發布我自己的方法來訪問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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM