3

In Cucumber(mvn based java project) we need to specify the location of files (e.g) feature file location in the TestRunner as below

@CucumberOptions(features=("src\\test\\resources\\features"),
                 glue= {"com.testing.stepdefinitions"},
                 strict = true,
                 plugin= {"pretty","html:target/cucumber",
                         "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"}
                 )

public class MyRunner extends BaseClass{
}

How to specific the file path such that it works properly in Windows and MAC ?

Karthikeyan
  • 125
  • 2
  • 13

2 Answers2

1

Please try the following instead of src\\test\\resources\\features. This will work in both windows and Mac.

@CucumberOptions(features=("./src/test/resources/features"),
Yosuva Arulanthu
  • 1,444
  • 4
  • 18
  • 32
0

For the feature attribute, replace \\ by / such as : src/test/resources/features.
It works in applications on which I use Cucumber (Windows and Unix based OS).
Note that the atrribute javadoc states :

Returns:

the uris to the feature(s)

An uri is composed of slashes, not of backslashes.

As a side note, the backslash is a windows specific way to express a path delimiter. The standard JDK classes that rely on the "path" concept such as File or Path will cope with with slashes on Linux and likewise on Windows. But the reverse is not true.

davidxxx
  • 125,838
  • 23
  • 214
  • 215
  • No , it actually worked when i put a "." in front of it like ./src/test/resources/features instead of just src/test/resources/features as a common path for both MAC and windows – Karthikeyan Oct 04 '19 at 16:17
  • That is very interesting. I don't have the issue with Ubuntu. – davidxxx Oct 04 '19 at 17:02