describe('#indexOf()'....
it('#doSth()');
Does '#' has special meaning in Mocha? What does describe
and it
actually do? sorry not found document for describe
and it
'#'在摩卡有特殊意义吗?描述和它实际上做了什么?抱歉没有找到描述文件和它
2 个解决方案
#1
8
describe
and it
follows a pattern called BDD
, which means "Behaviour Driven Development". It just defines an interface that makes you think a little different about how you write your tests, at least it should. Nesting of describe
also makes it possible to group your tests functionally, and the resulting report has a "readable" feeling to it.
描述它遵循称为BDD的模式,这意味着“行为驱动的开发”。它只是定义了一个界面,让您对编写测试的方式略有不同,至少应该如此。嵌入描述还可以在功能上对测试进行分组,并且生成的报告具有“可读”的感觉。
Quoting the example from the Mocha docs:
引用Mocha文档中的示例:
describe('Array', function(){
describe('#indexOf()', function(){
it('should return -1 when the value is not present', function(){
assert.equal(-1, [1,2,3].indexOf(5));
assert.equal(-1, [1,2,3].indexOf(0));
})
})
})
It reads:
Array#indexOf() should return -1 when the value is not present
当值不存在时,Array#indexOf()应返回-1
The first two describes just sets up the (descriptional/grouping) scope, and the it
is the actual test that is run. #
has no special meaning. In this case, it just makes the output text/report look a little more API-doc like.
前两个描述只是设置(描述/分组)范围,它是运行的实际测试。 #没有特殊意义。在这种情况下,它只是使输出文本/报告看起来更像API-doc。
#2
6
The '#' has no special meaning. It is a common standard to prefix # to a method for a certain class. e.g. Array#indexOf()
.
'#'没有特殊含义。将#添加到某个类的方法是一种通用标准。例如阵列#的indexOf()。
I had exactly the same questions on describe()
and it()
, which the documentation didn't explain much.
我对describe()和it()有完全相同的问题,文档没有解释得太多。
Hence I wrote a blog post on a guide to mocha. In short:
因此,我写了一篇关于摩卡指南的博客文章。简而言之:
-
describe()
is merely for grouping, which you can nest as deep. Also known as a test suite.describe()仅用于分组,您可以将其嵌套为深层。也称为测试套件。
-
it()
is a test caseit()是一个测试用例
#1
8
describe
and it
follows a pattern called BDD
, which means "Behaviour Driven Development". It just defines an interface that makes you think a little different about how you write your tests, at least it should. Nesting of describe
also makes it possible to group your tests functionally, and the resulting report has a "readable" feeling to it.
描述它遵循称为BDD的模式,这意味着“行为驱动的开发”。它只是定义了一个界面,让您对编写测试的方式略有不同,至少应该如此。嵌入描述还可以在功能上对测试进行分组,并且生成的报告具有“可读”的感觉。
Quoting the example from the Mocha docs:
引用Mocha文档中的示例:
describe('Array', function(){
describe('#indexOf()', function(){
it('should return -1 when the value is not present', function(){
assert.equal(-1, [1,2,3].indexOf(5));
assert.equal(-1, [1,2,3].indexOf(0));
})
})
})
It reads:
Array#indexOf() should return -1 when the value is not present
当值不存在时,Array#indexOf()应返回-1
The first two describes just sets up the (descriptional/grouping) scope, and the it
is the actual test that is run. #
has no special meaning. In this case, it just makes the output text/report look a little more API-doc like.
前两个描述只是设置(描述/分组)范围,它是运行的实际测试。 #没有特殊意义。在这种情况下,它只是使输出文本/报告看起来更像API-doc。
#2
6
The '#' has no special meaning. It is a common standard to prefix # to a method for a certain class. e.g. Array#indexOf()
.
'#'没有特殊含义。将#添加到某个类的方法是一种通用标准。例如阵列#的indexOf()。
I had exactly the same questions on describe()
and it()
, which the documentation didn't explain much.
我对describe()和it()有完全相同的问题,文档没有解释得太多。
Hence I wrote a blog post on a guide to mocha. In short:
因此,我写了一篇关于摩卡指南的博客文章。简而言之:
-
describe()
is merely for grouping, which you can nest as deep. Also known as a test suite.describe()仅用于分组,您可以将其嵌套为深层。也称为测试套件。
-
it()
is a test caseit()是一个测试用例