AndroidStudio黄瓜功能路径错误

时间:2020-03-28 13:12:09

标签: android-studio testing cucumber

我正在尝试将Cucumber与Android Studio一起使用,并且在检查了许多文档和相关文章之后,我没有摆脱使我发疯的错误。这是一个:

java.lang.IllegalArgumentException: path must exist: /src/androidTest/java/com/example/tetris/cucumber
at io.cucumber.core.resource.PathScanner.findResourcesForPath(PathScanner.java:42)
at io.cucumber.core.resource.PathScanner.findResourcesFo ...

这是我的目录树:

Text

这是我的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.tetris"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.2"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
configurations {
    cucumberRuntime {
        extendsFrom testImplementation
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.1.0'
    testImplementation 'junit:junit:4.13'

    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation group: 'io.cucumber', name: 'cucumber-java', version: '5.2.0'
    androidTestImplementation group: 'io.cucumber', name: 'cucumber-junit', version: '5.5.0'
    androidTestImplementation group: 'io.cucumber', name: 'cucumber-android', version: '4.2.5'
    androidTestImplementation group: 'io.cucumber', name: 'cucumber-picocontainer', version: '5.5.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
}

这是我的黄瓜赛跑者:

package com.example.tetris.cucumber;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions( features = "src/androidTest/java/com/example/tetris/cucumber" )
public class CucumberRunner {
}

这是我的HelloWorld功能:

Feature: HelloWorld

  Scenario: HelloToTheWorld
    Given Nothing
    When NothingAgain
    Then Hello

这是我要编写HelloWorld步骤的地方:

package com.example.tetris.cucumber;

import org.junit.Assert;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;


public class CucumberHello {
    @Given("^Nothing$")
    public void nothing() {
    }

    @When("^NothingAgain$")
    public void nothingagain() {
    }

    @Then("^Hello$")
    public void hello() {
        Assert.assertTrue(true);
    }
}

仅告诉您,如果我删除@CucumberOptions,该错误将更改为未找到测试 有人可以帮我吗?

注意:忽略文件中的红色,它们与Git有关,而不与编译错误有关。

大家都过得愉快。

0 个答案:

没有答案