我有 postman.collection.json 文件,我可以通过 newman 并使用以下命令运行这些集合文件。
newman run test.postman.collection.json -e environment.collection.json -d test.csv
运行成功,正在返回响应。
我只想通过使用 Maven 系统获得相同的行为。我需要将它与 pom.xml 集成,以便该文件将运行上述集合。
这可能吗?如果可以像这样运行,请分享一个示例来说明如何运行。
最佳答案
Maven 有一些非官方的 postman runner,like this或 this .我从未尝试过这些,所以我不能推荐其中任何一个。
我更喜欢使用 maven-exec-plugin
在 integration-test
或 verify
生命周期阶段运行 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/