Specify the feature file location in cucumber

后端 未结 5 1620
暖寄归人
暖寄归人 2021-01-05 09:49

I have created some cucumber test steps and a small Cucumber test case, which I run with JUnit like so:

@RunWith(Cucumber.class)

public class FuelCarTest {
         


        
5条回答
  •  逝去的感伤
    2021-01-05 09:54

    I have placed all feature files in test/resources/features and added my feature file location with class path. Here is my cucumber run file.

    @RunWith(Cucumber.class)
    @CucumberOptions(
        monochrome = true,
        features = "classpath:features",
        plugin = {"pretty", "html:target/cucumber-reports",
        "json:target/cucumber.json"
                 }
    
    )
    public class MyTests 
    {
    
    }
    

    This will pick all feature files inside the folder features. If you want to have a subfolders you can add that too by just replacing the line as shown below.

    features = "classpath:features/DEV"

    If only one particular feature file, it should be like this

    features = "classpath:features/DEV/SmokeTests.feature"

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题