使用不同的数据执行测试用例
Feature( 'loginaccount' );
let accounts = new DataTable([ 'login' , 'password' ]);
Data(accounts).Scenario( 'test something' , (I,current) => {
var cookie = "abc"
});
var cookie = "abc"
});
|
运行结果
CodeceptJS v2. 6.5
Using test root "E:Docoumentcodeceptdemo"
loginaccount --
√ test something | { "login" : "17600000000" , "password" : "12345678" } in 33313ms
√ test something | { "login" : "13500000000" , "password" : "12345678" } in 33500ms
S test something | { "login" : "15700000000" , "password" : "12345678" }
√ test something | { "login" : "17600000000" , "password" : "12345678" } in 33538ms
√ test something | { "login" : "13500000000" , "password" : "12345678" } in 32463ms
S test something | { "login" : "15700000000" , "password" : "12345678" }
OK | 4 passed, 2 skipped
|
筛选出数据集中account.login =="17610772739"的数据,并运行
Feature( 'loginaccount' );
let accounts = new DataTable([ 'login' , 'password' ]);
var cookie = "abc"
});
|
运行结果
CodeceptJS v2. 6.5
Using test root "E:Docoumentcodeceptdemo"
loginaccount --
√ test something | { "login" : "17600000000" , "password" : "12345678" } in 33422ms
√ test something | { "login" : "17600000000" , "password" : "12345678" } in 33360ms
√ test something | { "login" : "17600000000" , "password" : "12345678" } in 33238ms
OK | 3 passed
|
数据集也可以使用数组,生成器或函数进行定义
Data(function*() {
yield { login: '17600000000' ,password: '12345678' };
yield { login: '13500000000' ,password: '12345678' };
}).Scenario( 'test something' , (I,current) => {
var cookie = "abc"
});
|
运行结果
CodeceptJS v2. 6.5
Using test root "E:Docoumentcodeceptdemo"
loginaccount --
√ test something | { "login" : "17600000000" , "password" : "12345678" } in 32819ms
√ test something | { "login" : "13500000000" , "password" : "12345678" } in 33566ms
OK | 2 passed
|