【问题标题】:Cucumber: Is it possible to read .feature files from a folder on the android device?Cucumber:是否可以从 android 设备上的文件夹中读取 .feature 文件?
【发布时间】:2024-01-14 16:07:01
【问题描述】:

我使用 cucumber 来测试我的 android 应用程序。通过 CucumberOptions 我定义了功能文件(测试文件)的位置。在此示例中,文件位于“assets/tests/*”文件夹中。

@CucumberOptions(features = ["tests"], glue = ["com.myapp.cucumber.steps"])
class CucumberTestCase

是否可以为设备上的功能文件定义另一个文件夹(例如 sdcard)?

如果有人可以将功​​能文件复制到设备上的特定文件夹并且在运行 cucumber 测试时,这些文件也将由 cucumber 执行,那就太好了。

【问题讨论】:

    标签: android testing automated-tests cucumber


    【解决方案1】:

    @CucumberOptions(features = *yourpath*)

    您可以指定任何您想要的文件夹。

    喜欢: @CucumberOptions(features = sdcard/features)

    【讨论】:

    • 这不起作用。我在我的设备上创建了一个文件夹并在其中添加了一个功能文件(sdcard/features/somefile.feature)。我添加了 cucumberOptions 的路径:@CucumberOptions(features = ["/sdcard/features"]) 但是没有找到测试。我使用以下库: androidTestImplementation "io.cucumber:cucumber-android:4.3.1" androidTestImplementation "io.cucumber:cucumber-picocontainer:4.3.1" 有什么问题吗?
    • 1.为什么要使用路径数组?只需使用@CucumberOptions(features = "/sdcard/features"); 2. 你的路径不正确。我敢打赌你有一个例外,比如“ava.lang.IllegalArgumentException:不是文件或目录”。确保您使用正确的路径。它应该像:@CucumberOptions(features = sdcard/features not /sdcard/features
    • 关于您的进口。您只需要 cucumber-java 工件库。就这样。我的意思正是为了这个目的
    • 我必须使用数组,因为代码是用 Kotlin 编写的。在Java中是不同的。我尝试了不同的路径变体:“sdcard/features”、“/sdcard/features”、“/sdcard/features/”、“sdcard/features/”。我收到警告:W/turePathFeatureSupplier: No features found at file:sdcard/features/
    • 我猜某些 SD 卡有问题。设置断点并尝试从此磁盘打开任何功能文件
    【解决方案2】:

    github 上已经有针对此问题的拉取请求。 https://github.com/cucumber/cucumber-android/issues/32

    因此,目前无法加载与资产文件夹不相关的功能文件。但希望很快。

    【讨论】: