有
ActionManager.js从文件夹中读取具有所有可能测试功能的文件(库);
WorkflowManager.js读取包含所需测试描述的文件(测试工作流)。每个文件都包含一系列动作和参数。
TestsRunner.js需要并运行 ActionManager 和 WorkflowManager。之后,我想使用参数运行每个测试工作流的操作(执行 Jasmine 测试)。
如何让这个过程认真执行?
我试图将 runner 实现为:
在describe块之前调用 require ,所以 Jasmine 的测试在此之前运行
将 require 放入beforeEach,所以 beforeEach 在执行it()之前被调用;所以我知道在需要和获取流数组之后循环它()的流的数量;但是当it()执行时,它应该已经从已经定义的循环迭代中调用
我将模拟描述块与 it() 放在主要描述下进行初始化,但在这种情况下,循环 for() 将流量数量设为 0,然后所有描述开始执行并初始化数量
我将两个 decribe 包装成一个 else -> decribe和it之间的代码,describe和 inner for循环没有执行。
这是代码的一部分,只需要 WorkflowManager 并在每次迭代时使用控制台输出循环工作流数组大小。
var firstTime = true;
beforeEach(function() {
if (firstTime) {
var flow = protractor.promise.controlFlow();
flow.execute(function() {
console.log("I'm beforeach part#1");
path = require("path");
testsPath = path.resolve("./e2e/tests/");
//requiring WorkflowManager
wfMng = require('./utils/WorkflowManager.js');
}).then(function() {
console.log("I'm beforeeach part#2");
var workflowPath = path.resolve("./e2e/data/workflows/");
//getting array of worklows
wfs = wfMng.getAllWorkflows(workflowPath + '\\');
}).then(function() {
console.log("I'm beforeeach part#3");
//console output of length of workflows array = 1 - is correct
console.log("Length of array in before each after initing " + wfs.length); //LENGTH = 1
firstTime = false;
})
}
});
describe("Describe for initialization", function() {
it("It block for initialization", function() {
expect(0).toEqual(0);
console.log("Length in 1st describe: " + wfs.length); //LENGTH = 1
});
});
describe("Core describe", function() {
console.log("This console log doesn't executed!!!!");
//CYCLE ISN'T EXECUTED - LENGTH = 0
for (var workflowidx = 0, wlen = wfs.length; workflowidx < wlen; workflowidx += 1) {
(function(widx) {
console.log("Length in for cycle: " + wfs.length);
describe("SBB" + widx, function() {
console.log("This console log doesn't executed!!!!");
it("My test" + widx, function() {
expect(2).toEqual(2);
console.log("Length in it func: " + wfs.length); //LENGTH = 1
});
});
})(workflowidx);
};
});
如何处理这两个需求,获取可能的操作和所需工作流的数组,然后执行循环中的每个操作?
我应该以某种方式使用Jasmine 的间谍吗?
Node.JS v0.10.30
量角器 v 1.0.0