0

集合有两个请求。

  • 发布 - 创建帐户
  • 发布 - 创建 AccountProfile

创建 AccountProfile 将 AccountProfile 对象添加到 Account。

有 13 种帐户配置文件类型。

我想要做的是创建 13 个帐户,每个帐户类型一个。

这是Tests第二种方法的Javascript。

暂时不要介意硬编码。我稍后会解决这个问题。

var acctProfiles = [0,1,4,5,6,19,33,34,35,38,39,40]

for (var p in acctProfiles ) {
    // Create account with that profile
    console.log('creating account');
    postman.setNextRequest("Create Account");

    console.log(pm.collectionVariables.get("accountToken"));

    pm.collectionVariables.set("profileType", profiles[p]);

    console.log('creating profile');

    // Now call this request to create the profile
    postman.setNextRequest(); 

}

我在集合运行器中运行了这个集合。它成功地运行了每个请求,但只运行了一次。
它仅使用数组中的最后一个元素 40。因此,创建了一个具有一个帐户配置文件的帐户,仅此而已。

4

1 回答 1

0

邮递员中的 for 循环不起作用。

每次您在 Create AccountProfile 中使用时,它都会setNextRequest();Create AccountProfile中的整个代码不仅执行循环之后转到Create Account 。因此,只会执行循环中的第一次执行。

你可以通过另一种方式实现你所需要的。您可以将数组存储在全局变量中,每次执行Create AccountProfile时,您都可以从中删除一项。

于 2020-01-09T11:29:54.503 回答