【问题标题】:How to integrate postman collection in maven pom.xml如何在 maven pom.xml 中集成邮递员集合
【发布时间】:2019-11-17 14:31:43
【问题描述】:

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

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

它运行成功并且正在返回响应。

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

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

【问题讨论】:

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


    【解决方案1】:

    Maven 有一些非官方的邮递员,like thisthis。我从来没有尝试过这些,所以我不能推荐其中任何一个。

    我更喜欢在integration-testverify 生命周期阶段使用maven-exec-plugin 运行邮递员/纽曼集合。

    <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>
    

    【讨论】:

    • 似乎是一个解决方案,但是如何检查测试是否成功?
    【解决方案2】:

    此外,您可以将可用的 newman 集成到 Maven docker 映像中并作为管道运行。

        spec:
      containers:
      - image: "miksonx/node-newman-maven"
        imagePullPolicy: "Always"
        name: "maven"
        tty: true
    """
    ...
       stages {
           stage('Unit Test') {
               agent{
                   kubernetes {
                       yaml NodeNewmanMaven
                   }
               }
               steps {
                   container(MVN_AGENT) {
                       sh 'mvn clean integration-test'
                   }
               }
        }
    

    https://miksonx.wordpress.com/2021/04/19/postman-newman-using-maven-under-jenkins-kuberenets/

    【讨论】:

    • 此链接没有说明如何执行此操作...
    猜你喜欢
    • 1970-01-01
    • 2019-02-16
    • 2020-07-01
    • 2020-01-04
    • 1970-01-01
    • 2020-05-10
    • 1970-01-01
    • 2019-02-20
    • 2016-02-03
    相关资源
    最近更新 更多