問(wèn)題描述
我需要知道是否有辦法包含或使用 beforeAll 函數(shù)或類似函數(shù),以便我可以登錄到我的應(yīng)用程序然后開始測(cè)試.
I need to know if there is a way to include or use a beforeAll function, or something similar, so I can login to my application and then start testing.
現(xiàn)在我將登錄操作放在第一個(gè)測(cè)試用例 ( it
) 中.這不是一個(gè)好習(xí)慣.
Right now I'm putting my login operations in the first test case ( it
). Which is not a good practice.
如果有更好的方法來(lái)存儲(chǔ)我的登錄代碼而不是使用 beforeAll 函數(shù),請(qǐng)告訴我.
If there is a better way to store my login code other then using a beforeAll function please tell me about it.
我正在使用與咖啡腳本或其他任何其他框架無(wú)關(guān)的純 Jasmine.
I'm using pure Jasmine not related to any other framework like coffee-script or others.
謝謝
推薦答案
現(xiàn)在這更容易了.從 Jasmine 2.1(2014 年 11 月 14 日發(fā)布)開始,框架中內(nèi)置了一個(gè) beforeAll
函數(shù).
This is now much easier. As of Jasmine 2.1 (released 14 Nov 2014), there is a beforeAll
function built into the framework.
這里是發(fā)行說(shuō)明在 2.1 中添加.這里是文檔 解釋 beforeAll
和畢竟
Here are the release notes with everything that was added in 2.1. And here is the documentation explaining beforeAll
and afterAll
這篇關(guān)于我怎樣才能在 Jasmine 中有一個(gè) beforeAll 函數(shù)?(不是咖啡腳本)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!