node.js - 如何在 maven pom.xml 中集成 postman 集合

标签 node.js maven newman postman-collection-runner

我有 postman.collection.json 文件,我可以通过 newman 并使用以下命令运行这些集合文件。

   newman run test.postman.collection.json -e environment.collection.json -d test.csv 

运行成功,正在返回响应。

我只想通过使用 Maven 系统获得相同的行为。我需要将它与 pom.xml 集成,以便该文件将运行上述集合。

这可能吗?如果可以像这样运行,请分享一个示例来说明如何运行。

最佳答案

Maven 有一些非官方的 postman runner,like thisthis .我从未尝试过这些,所以我不能推荐其中任何一个。

我更喜欢使用 maven-exec-pluginintegration-testverify 生命周期阶段运行 postman/newman 集合。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
    <executions>
        <execution>
            <id>integration-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>
                    <!-- PATH_TO_NEWMAN_EXECUTABLE-->
                </executable>
                <commandlineArgs>
                    run <!--PATH_TO_COLLECTION_JSON--> -e <!--PATH_TO_ENVIRONMENT_JSON-->
                </commandlineArgs>
            </configuration>
        </execution>
    </executions>
</plugin>

关于node.js - 如何在 maven pom.xml 中集成 postman 集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58901502/

相关文章:

javascript - 如何在 puppeteer 中滚动浏览多个 iframe

javascript - 如何修复 "can' t read property push of undefined"error in Nodejs?

java - 在maven pom.xml中总是需要更改vault插件的版本

java - vaadin touchkit 示例应用程序 -- 没有 ivy.xml

ssl - Newman 加载 pfx 证书,但不用于连接到端点

ssl - 如何修复 Newman 错误自签名证书?

javascript - 原生地从对象中提取属性

node.js - AWS Lambda SNS 事件未使用无服务器 yml 绑定(bind)到正确的 SNS 主题 ARN

java - 在maven项目中保存java文件失败

node.js - 如何让Newman的 Node 脚本在测试失败时失败