【问题标题】:Executing Karate Test suite执行空手道测试套件
【发布时间】:2019-09-01 12:46:59
【问题描述】:

我正在为空手道的小演示做准备,我有以下 git 项目https://github.com/TheRasanjana/karateTesting。我正在构建一个具有多个功能的测试套件。我有模拟products.feature,我正在用我的productRunner.java 调用它。由于我希望将来将其与 jenkins 集成,因此我希望将所有这些作为单个测试套件执行。

当我分别运行每个运行器类时,测试运行成功。我在功能之外有一个“AllTest.java”运行器类,可以使用命令“mvn test -Dtest=AllTest”将它们全部作为一个套件运行。但在这种情况下,它不会调用模拟。我是否也必须调用 AllTests.java 中的模拟?

将所有功能作为一个套件运行的正确方法是什么?

【问题讨论】:

    标签: karate web-api-testing


    【解决方案1】:

    在 CI 中运行模拟的最佳方式是 a) 使用 JUnit 和 b) 在测试执行中包含 JUnit 类。所以你需要做的就是mvn test 并且你可以停止引用任何特定的测试运行器类。

    实际上,如果您将productsRunner 重命名为ProductsTest,事情很可能会按照您期望的方式开始工作。如果您将@ignore 添加到products.feature(因此它们被排除在AllTest 之外并在ProductsTest 中使用@KarateOptions(features = "classpath:features/products/products.feature"),那么您就完成了。

    空手道回归测试使用替代方法,将ProductsRunner 明确添加到pom.xmlmaven-surefire 部分。

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.version}</version>
                    <configuration>
                        <includes>
                            <include>demo/DemoTestParallel.java</include>
                            <include>mock/contract/*Test.java</include>
                            <include>mock/micro/*Runner.java</include>
                            <include>mock/proxy/*Runner.java</include>
                            <include>ssl/*Test.java</include>
                        </includes>
                    </configuration>
                </plugin>   
    

    查看example 并阅读文档:https://github.com/intuit/karate#command-line

    【讨论】:

    • 非常感谢您的快速回复。如果我让您正确,您所说的是从 AllTest.java 中排除 products.feature 并运行 AllTest 也会运行 ProductsTest?
    • @NironRasanjanaPerera 我意识到我没有明确表示您只需要这样做mvn test 我认为这就是您所缺少的。编辑了我的答案。
    • 感谢您的回复。我有点困惑。无论如何,它如你所说。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-24
    • 1970-01-01
    • 2020-06-18
    相关资源
    最近更新 更多