在Postman中是否只运行部分请求?

在Postman中是否只运行部分请求?,postman,postman-collection-runner,Postman,Postman Collection Runner,我们在Postman中有许多API级的自动化测试作为请求集合编写 我们有一个脚本,可以自动运行所有集合 是否有一种方法可以只标记/运行请求的子集,例如使用一些标签,例如作为smoke suite,而不将请求复制到新集合,然后显式运行(因为这需要在两个位置维护相同的测试…) 可能存在跳过请求的标签、组或脚本。如果设置了环境变量…您可以创建文件夹并组织测试,如 烟雾和回归 只吸烟等 当使用newman作为命令行工具时,可以使用--folder arguent指定要运行的文件夹 您还可以使用postm

我们在Postman中有许多API级的自动化测试作为请求集合编写

我们有一个脚本,可以自动运行所有集合

是否有一种方法可以只标记/运行请求的子集,例如使用一些标签,例如作为smoke suite,而不将请求复制到新集合,然后显式运行(因为这需要在两个位置维护相同的测试…)


可能存在跳过请求的标签、组或脚本。如果设置了环境变量…

您可以创建文件夹并组织测试,如

  • 烟雾和回归
  • 只吸烟等
  • 当使用newman作为命令行工具时,可以使用--folder arguent指定要运行的文件夹

    您还可以使用postman.setNextRequest控制执行流

    您还可以将newman作为npm模块运行

    您只需要编写一个逻辑来读取集合文件,获取包含eg“smoke”的所有文件夹名称,并将其作为数组传递

    const newman = require('newman'); // require newman in your project
    
     
    
    // call newman.run to pass `options` object and wait for callback
    newman.run({
        collection: require('./sample-collection.json'),
        reporters: 'cli',
        folder: folders
    }, function (err) {
        if (err) { throw err; }
        console.log('collection run complete!');
    });
    
    只需更新评论: 在新旧界面中,您可以选择要在collection runner中执行的文件夹


    您可以创建文件夹并组织测试,如

  • 烟雾和回归
  • 只吸烟等
  • 当使用newman作为命令行工具时,可以使用--folder arguent指定要运行的文件夹

    您还可以使用postman.setNextRequest控制执行流

    您还可以将newman作为npm模块运行

    您只需要编写一个逻辑来读取集合文件,获取包含eg“smoke”的所有文件夹名称,并将其作为数组传递

    const newman = require('newman'); // require newman in your project
    
     
    
    // call newman.run to pass `options` object and wait for callback
    newman.run({
        collection: require('./sample-collection.json'),
        reporters: 'cli',
        folder: folders
    }, function (err) {
        if (err) { throw err; }
        console.log('collection run complete!');
    });
    
    只需更新评论: 在新旧界面中,您可以选择要在collection runner中执行的文件夹

    获取集合中的所有请求: 您还可以使用以下命令获取集合中所有请求的信息:

    https://api.getpostman.com/collections/{{collection_UUID}}
    
    https://app.getpostman.com
    
    get user details [Regression][Smoke][Somethingelse]
    get account details [Regression]
    
    if (pm.info.requestName !== "initial request") {
        let requestToRun = pm.environment.get("requestToRun")
        let val = requestToRun.pop()
        pm.environment.set("requestToRun", requestToRun)
        val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    }
    
    获取uuid和api密钥转到:

    https://api.getpostman.com/collections/{{collection_UUID}}
    
    https://app.getpostman.com
    
    get user details [Regression][Smoke][Somethingelse]
    get account details [Regression]
    
    if (pm.info.requestName !== "initial request") {
        let requestToRun = pm.environment.get("requestToRun")
        let val = requestToRun.pop()
        pm.environment.set("requestToRun", requestToRun)
        val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    }
    
    现在生成api密钥>

    转到帐户设置>api密钥并生成api密钥

    要获取集合uuid,请转到特定的工作区和集合,并从url复制uuid部分:

    现在在你的收藏中 将所有请求重命名为:

    https://api.getpostman.com/collections/{{collection_UUID}}
    
    https://app.getpostman.com
    
    get user details [Regression][Smoke][Somethingelse]
    get account details [Regression]
    
    if (pm.info.requestName !== "initial request") {
        let requestToRun = pm.environment.get("requestToRun")
        let val = requestToRun.pop()
        pm.environment.set("requestToRun", requestToRun)
        val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    }
    
    然后创建一个名为initial request的新请求,并将其保留为集合中的第一个请求: 网址:

    授权:apikey头:key:X-Api-key和value:yourapikey

    测试脚本

    pm.environment.unset("requestToRun")
    reqeustlist = pm.response.json().collection.item.map((a) => a.name)
    requestToRun = reqeustlist.filter((a) => a.includes(pm.environment.get("tag")))
    let val = requestToRun.pop()
    pm.environment.set("requestToRun", requestToRun)
    val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    
    现在将envirnoment变量设置为您想要查找的变量,例如:运行包含文本“Regression”的脚本,然后设置
    pm.environment.set(“tag”,“Regression”)

    现在在您的收藏中预先请求添加:

    https://api.getpostman.com/collections/{{collection_UUID}}
    
    https://app.getpostman.com
    
    get user details [Regression][Smoke][Somethingelse]
    get account details [Regression]
    
    if (pm.info.requestName !== "initial request") {
        let requestToRun = pm.environment.get("requestToRun")
        let val = requestToRun.pop()
        pm.environment.set("requestToRun", requestToRun)
        val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    }
    
    输出:

    示例集合:

    仅运行名称中包含“Copy”的请求

    获取集合中的所有请求: 您还可以使用以下命令获取集合中所有请求的信息:

    https://api.getpostman.com/collections/{{collection_UUID}}
    
    https://app.getpostman.com
    
    get user details [Regression][Smoke][Somethingelse]
    get account details [Regression]
    
    if (pm.info.requestName !== "initial request") {
        let requestToRun = pm.environment.get("requestToRun")
        let val = requestToRun.pop()
        pm.environment.set("requestToRun", requestToRun)
        val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    }
    
    获取uuid和api密钥转到:

    https://api.getpostman.com/collections/{{collection_UUID}}
    
    https://app.getpostman.com
    
    get user details [Regression][Smoke][Somethingelse]
    get account details [Regression]
    
    if (pm.info.requestName !== "initial request") {
        let requestToRun = pm.environment.get("requestToRun")
        let val = requestToRun.pop()
        pm.environment.set("requestToRun", requestToRun)
        val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    }
    
    现在生成api密钥>

    转到帐户设置>api密钥并生成api密钥

    要获取集合uuid,请转到特定的工作区和集合,并从url复制uuid部分:

    现在在你的收藏中 将所有请求重命名为:

    https://api.getpostman.com/collections/{{collection_UUID}}
    
    https://app.getpostman.com
    
    get user details [Regression][Smoke][Somethingelse]
    get account details [Regression]
    
    if (pm.info.requestName !== "initial request") {
        let requestToRun = pm.environment.get("requestToRun")
        let val = requestToRun.pop()
        pm.environment.set("requestToRun", requestToRun)
        val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    }
    
    然后创建一个名为initial request的新请求,并将其保留为集合中的第一个请求: 网址:

    授权:apikey头:key:X-Api-key和value:yourapikey

    测试脚本

    pm.environment.unset("requestToRun")
    reqeustlist = pm.response.json().collection.item.map((a) => a.name)
    requestToRun = reqeustlist.filter((a) => a.includes(pm.environment.get("tag")))
    let val = requestToRun.pop()
    pm.environment.set("requestToRun", requestToRun)
    val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    
    现在将envirnoment变量设置为您想要查找的变量,例如:运行包含文本“Regression”的脚本,然后设置
    pm.environment.set(“tag”,“Regression”)

    现在在您的收藏中预先请求添加:

    https://api.getpostman.com/collections/{{collection_UUID}}
    
    https://app.getpostman.com
    
    get user details [Regression][Smoke][Somethingelse]
    get account details [Regression]
    
    if (pm.info.requestName !== "initial request") {
        let requestToRun = pm.environment.get("requestToRun")
        let val = requestToRun.pop()
        pm.environment.set("requestToRun", requestToRun)
        val ? postman.setNextRequest(val) : postman.setNextRequest(null)
    }
    
    输出:

    示例集合:


    只运行名称为“复制”的请求必须有比创建大量冗余的文件夹更好的方法。大概但它真的感觉应该有一个功能,可以禁用基于某个环境变量的查询,过滤要在Runner中运行的查询或类似的功能。添加一个示例,只需按ctrol+o导入并选择链接,并使用该链接。要做到这一点,必须有比创建大量冗余的文件夹更好的方法。大概但它真的感觉应该有一个功能,可以禁用基于某个环境变量的查询,过滤要在Runner中运行的查询或类似的功能。添加一个示例,只需按Ctrl+o导入并选择link,用这个link@Rob以前的版本中也有:)在collection runner中,您可以查看LCT并取消选择要运行的请求或集合。您可以在旧应用程序中的postman collection runner ui中选择文件夹。此外,您还可以在“请接受”或“升级投票”中下载以前的版本,如果有帮助,请接受或升级投票anyways@Rob就在那里在以前的版本中:)在collection runner中,您可以查看LCT并取消选择要运行的请求或集合。您可以在旧应用程序中的postman collection runner ui中选择文件夹。此外,您还可以在处下载以前的版本,请确实接受或更新投票,如果有任何帮助