I'm trying to start using Cucumber with Android Studio and after checking a lot of documentation and related posts I don't get rid of an error that is driving me mad. This is the one:
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 ...
This is my directory tree:
This is my 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'
}
This is my Cucumber Runner:
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 {
}
This is my HelloWorld Feature:
Feature: HelloWorld
Scenario: HelloToTheWorld
Given Nothing
When NothingAgain
Then Hello
And this is where I wanted to write the HelloWorld steps:
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);
}
}
Just to let you know, if I delete the @CucumberOptions, the error changes to No Test Were Found Could someone please help me?
Note: Ignore the red colors in files, they are about Git and not Compilation Errors.
Have a nice day everyone.
Aucun commentaire:
Enregistrer un commentaire