代码之家  ›  专栏  ›  技术社区  ›  Krishnadas PC

使用nightwatchjs中的新数据再次重复步骤

  •  0
  • Krishnadas PC  · 技术社区  · 8 年前

    module.exports =
      {
        "ReadCsv" : function(client) {
            // This will have an array of csvData
        },
        "StepOne" : function(client) {
          //Code goes there...
        },
        "StepTwo" : function(client) {
          //Code goes there...
        },
        "StepThree" : function(client) {
          //Code goes there...
        },
      }
    

    我想重复第一步、第二步&第三步是对每行csvData进行测试,以便可以测试所有内容。我试过的是

    "loopUntilEnd" : function(client)
        {
            for (var i = 1; i < csvData.length; i++)
            {            
                this.StepOne(client, csvData[i])
                this.StepTwo(client)
                this.StepThree(client)   
    
            }
        },
    

    但它不起作用。

    1 回复  |  直到 8 年前
        1
  •  0
  •   Krishnadas PC    8 年前

    我发现的解决方案是使用bash脚本,循环csv数据,并执行nightwatchjs,直到一切完成。

    我的shell脚本将是这样的。

    #!/bin/bash
    export IFS=","
    cat mycsv.csv |
        while read a b c d;
            do echo "$a:$b:$c:$d";
            nightwatch -t tests/test-script.js $a:$b:$c:$d;
        done
    

    global.js

    CSV_DATA : process.argv[4].split(":").join(" "),