Javascript 我可以先喝两杯再喝一杯吗?
我对一个应用程序页面的所有测试用例都有一个描述。我有一个包含所有积极测试用例的上下文,然后有一个包含所有消极测试用例的上下文。在所有测试用例之前,我有一个包括登录的测试用例。我想知道,我可以为阴性测试用例添加另一个 例如:Javascript 我可以先喝两杯再喝一杯吗?,javascript,automation,mocha.js,hook,webdriver-io,Javascript,Automation,Mocha.js,Hook,Webdriver Io,我对一个应用程序页面的所有测试用例都有一个描述。我有一个包含所有积极测试用例的上下文,然后有一个包含所有消极测试用例的上下文。在所有测试用例之前,我有一个包括登录的测试用例。我想知道,我可以为阴性测试用例添加另一个 例如: describe('X page', function (){ context('As a user', function (){ before(function(){ login goes here }); it('Test case
describe('X page', function (){
context('As a user', function (){
before(function(){
login goes here
});
it('Test case 1', function (){
test case implementation goes here
});
it('Test case 2', function (){
test case implementation goes here
});
context('Negative tests', function (){
before(function(){
negative tests precondition goes here
});
it('Test case 1', function (){
test case implementation goes here
});
it('Test case 2', function (){
test case implementation goes here
});
});
});
});
在去那里之前的那一秒可以吗?是的,你可以。外部
descripe
中的before
钩子在内部descripe
中的钩子之前执行。如果在描述的同一回调中有多个之前的钩子,它们将按出现的顺序执行。(注意descripe
是context
的同义词:摩卡为两者分配相同的功能。)