Jasmine裏的describe,it和expect函數 describe it Expectation

describe

將一系列業務相關的specs關聯在一起,每個測試實現文件的top level至少有一個describe. 字符串參數是爲了命名這些spec的集合。

The describe function is for grouping related specs, typically each test file has one at the top level. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec's full name.

例子:

it

使用it函數定義spec,一個spec裏包含了一個或者多個expectation.

Expectation

An expectation in Jasmine is an assertion that is either true or false. A spec with all true expectations is a passing spec. A spec with one or more false expectations is a failing spec.

Expectation就是assertion.

JavaScript scoping rules apply, so variables declared in a describe are available to any it block inside the suite.

定義在describe裏的變量可以在任意的it區塊內訪問。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章