如何访问当前黄瓜项目中其他黄瓜项目中可用的步骤

时间:2016-06-17 09:18:42

标签: cucumber

请帮助我了解当前黄瓜项目中其他黄瓜项目的可用步骤。 我也试过胶水选项,我也在maven依赖项中添加了其他黄瓜项目jar文件,但无法使其工作。

以下是project1的功能文件:         特点:测试黄瓜测试正在运行         我想运行一个示例功能文件。

     Scenario: cucumber setup

    Given sample feature file is ready1
    When I run the feature file1
    Then run should be successful1

    Scenario: cucumber setup for cucmbertestautomation2

    Given sample feature file is ready2
    When I run the feature file2
    Then run should be successful2

“如果样本要素文件已准备就绪2”步骤在project2中可用。

和project1(cucumbertestautomation1)POM将project2(cucumbertestautomation2)作为依赖项:                      com.celcom             cucumbertestautomation2             0.0.1-SNAPSHOT         

仍然无法识别“给定样本特征文件就绪2”的步骤,而项目2(cucumbertestautomation2)中存在这一步骤,作为依赖项添加。

2 个答案:

答案 0 :(得分:1)

The steps Cucumber will search for just live in a package, or a sub-package from the runner.

If you have steps from somewhere else, added as a dependency through a jar or similar, then these steps will be found.

They way to re-use steps is therefore to package the steps in a jar and add that jar as a dependency. You can use Maven for creating the jar.

答案 1 :(得分:0)

Cucumber只知道如何读取和执行您的功能文件,因为步骤定义文件通常在steps目录中定义,并且调用类似step_definitions.rb的内容。这是您定期捕获功能语句的地方表达式并转换为Ruby代码。

我的建议是将Project 2中的步骤定义包含在Project 1的步骤目录中。