【问题标题】:Cucumber test scenarios running in parallel?并行运行的黄瓜测试场景?
【发布时间】:2017-05-25 01:11:04
【问题描述】:

我的项目中有几个测试功能,到目前为止,我正在使用具有线程数的运行器类并行运行它们。但是这里的问题是优化执行时间,因为这些线程需要更长的时间来完成测试场景

有没有更好的方法来并行执行测试场景??

任何帮助.. 非常感谢!

【问题讨论】:

标签: multithreading selenium selenium-webdriver cucumber cucumber-jvm


【解决方案1】:

看看 Courgette-JVM

它增加了在功能级别或场景级别并行运行黄瓜测试的功能。

它还提供了自动重新运行失败场景的选项。

用法

@RunWith(Courgette.class)
@CourgetteOptions(
    threads = 10,
    runLevel = CourgetteRunLevel.SCENARIO,
    rerunFailedScenarios = true,
    showTestOutput = true,
    cucumberOptions = @CucumberOptions(
            features = "src/test/resources/features",
            glue = "steps",
            tags = {"@regression"},
            plugin = {
                    "pretty",
                    "json:target/courgette-report/courgette.json",
                    "html:target/courgette-report/courgette.html"}
    ))
    public class RegressionTestSuite {
    }

【讨论】:

  • 当我尝试使用 Courgette 运行时,出现下一个错误:线程“main”中的异常 java.lang.NoClassDefFoundError: io/cucumber/core/sn-ps/SnippetType。引起:java.lang.ClassNotFoundException: io.cucumber.core.sn-ps.SnippetType
  • 检查您的跑步者类和步骤在项目结构中是否正确定义
【解决方案2】:

尝试使用QAF gherkin 它并行运行场景而不是功能。您需要使用框架提供的工厂类并使用 testNG xml 配置您的执行。以下是示例配置文件:

<test name="Gherkin-QAF-Test" parallel="methods">
   <parameter name="step.provider.pkg" value="com.qmetry.qaf.automation.impl.step.qaf" />
   <parameter name="scenario.file.loc" value="resources/features" />
   <classes>
      <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
   </classes>
</test>

以上配置将并行运行resources/features 下的功能文件中可用的场景。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多