1. //integration文件下新建testLogin.data.js
    2. export const testLoginUser = [
    3. {
    4. summary: "Login pass",
    5. username: "jane.lane",
    6. password: "password123"
    7. },
    8. {
    9. summary: "Login fail",
    10. username: "iTesting",
    11. password: "iTesting"
    12. }
    13. ]
    1. // integration文件下新建testLogin.js
    2. ///<reference types="cypress" />
    3. // 导入测试数据
    4. import {testLoginUser} from './testLogin.data'
    5. describe('动态生成测试用例', function(){
    6. // 此用户名和密码为本地服务器默认
    7. const username = 'jane.lane'
    8. const password = 'password123'
    9. context('HTML 表单登陆测试', function(){
    10. for(const user of testLoginUser){
    11. it(user.summary, function(){
    12. cy.log(user.username);
    13. cy.log(user.password);
    14. });
    15. };
    16. });
    17. });

    执行命令:”yarn cypress open”,生成了两条测试用例。
    image.png