java 执行多个黄瓜特征文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38984295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 03:59:22  来源:igfitidea点击:

execute multiple cucumber feature files

javaseleniumcucumber

提问by sri

When I submit a single feature file it works perfectly. I want to pass features folder path which has multiple feature files into runner script. Can anyone help to execute multiple feature files?

当我提交单个功能文件时,它可以完美运行。我想将具有多个功能文件的功能文件夹路径传递到运行脚本中。任何人都可以帮助执行多个功能文件吗?

All feature files have same steps but data is different and file name is different.

所有特征文件步骤相同,但数据不同,文件名不同。

@RunWith(Cucumber.class)

@CucumberOptions(format = {"pretty"}, features =
"C:\TESTER\Execution\uidata\featurefiles\",
        glue={"com.test.auto.stepdefs"},dryRun=false) 

public class CucumberTest { 

}

I appreciate you help.

我很感激你的帮助。

采纳答案by Himadri

This is for Java-Cucumber users :: Multiple Features are 1.Smoketest 2. Logintest Then your Junit runner java file should look like

这是针对 Java-Cucumber 用户的 :: 多个功能是 1.Smoketest 2.Logintest 那么你的 Junit runner java 文件应该看起来像

@RunWith(Cucumber.class)    
    @CucumberOptions 
    (features = "src/test/java/testStep/",#Path for the Feature files Folder.Given you have smoke.feature and login.feature files present in the Path#
    plugin ={"pretty","html:reports/test-report"},#Path for the Reports Html Folder#
    tags= {"@smoke,@login"})#Declaring multiple Feature names of files#

-- Cheers

——干杯

回答by Eugene S

The features path must be relative to your project classpath. For example it can look like this:

功能路径必须相对于您的项目类路径。例如,它看起来像这样:

@CucumberOptions(features = {"classpath:features_folder1", "classpath:features_folder2"}, ...)

or

或者

@CucumberOptions(features="src/test/resources")

回答by Ramesh C

You can also use Cucumber Command-Line Interface Runner (CLI Runner) cucumber.api.cli.Mainand pass the path to the folder containing feature files as command line option.

您还可以使用 Cucumber 命令行界面运行程序 (CLI Runner)cucumber.api.cli.Main并将路径传递到包含功能文件的文件夹作为命令行选项。

Example:

例子:

java cucumber.api.cli.Main --glue com.my.stepdefn --plugin html:C:\testreports C:\features\ 

com.my.stepdefnis the package having the cucumber step definitions

com.my.stepdefn是包含黄瓜步骤定义的包

C:\features\is the folder containing the feature files

C:\features\是包含特征文件的文件夹

C:\testreportsis the folder where the cucumber html report will be generated.

C:\testreports是将生成黄瓜 html 报告的文件夹。