首页 > 解决方案 > 如何在茉莉花的 IT 规格中运行 for 循环?

问题描述

1/ 以下是我的规格

function testRunner(count) {
      it('test', async function () {
            console.log(count+"FIRST")
            for(var j=0;j<count.length;j++)
            { 
                console.log(count+"SECOND")
                specExecutor.execute(test)
            }       
      });
    } 


  count = 1
  for (var i=1; i<5; i++) {
        count = count+1;
        testRunner(count); //run testrunner 2 times; count = 2
    } 

当我运行上面的代码时,spec 中的 for 循环根本不会执行,因此specExecutor.exeute不会触发。

如何处理这样的用例?

我的要求是根据计数在一个规范内执行多个测试,以便所有结果都在所需的规范之下。

标签: javascriptjasmineprotractor

解决方案


它不是 testRunner 函数内循环中的 count.length 。这只是计数

for(var j=0;j<count;j++) { 
  console.log(count+"SECOND")
  specExecutor.execute(test)
}       

推荐阅读