Issue
I have a problem with Cucumber, I can't start tests, all the time I have the same problem, and have no idea how to fix it.
When I run tests I got this message:
Started running tests
Test running failed: Instrumentation run failed due to 'cucumber.runtime.CucumberException'
Empty test suite.
My build.gradle
android {
....
sourceSets {
androidTest {
assets.srcDirs = ['src/androidTest/assets']
}
}
}
dependencies {...
//Testing
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile('info.cukes:cucumber-android:1.2.4') {
exclude module: 'cucumber-jvm-deps'
exclude module: 'guava'
}
androidTestCompile 'info.cukes:cucumber-jvm-deps:1.0.3'
Cucumber Runner:
CucumberOptions(features = "features/Test.feature")
public class CucumberInstrumentationRunner extends MonitoringInstrumentation {
private final CucumberInstrumentationCore instrumentationCore = new CucumberInstrumentationCore(this);
@Override
public void onCreate(final Bundle bundle) {
super.onCreate(bundle);
instrumentationCore.create(bundle);
start();
}
@Override
public void onStart() {
waitForIdleSync();
instrumentationCore.start();
}
}
Test.feature
Scenario: Пользователь пытается авторизоваться используя неверные логин и пароль
Given I've launched "com.example.activities.LoginActivity"
When User '[email protected]' singIn with password 'wrongPassword'
Then Check message about incorrect password
and LoginActivitySteps
public class LoginActivitySteps extends InstrumentationTestCase {
// ViewInteractions
private final ViewInteraction mEmailEdt = onView(withId(R.id.edt_email));
private final ViewInteraction mPassEdt = onView(withId(R.id.edt_pass));
private final ViewInteraction mLoginBtn = onView(withId(R.id.button_login));
private Activity currentActivity;
@Given("^I've launched \"([^\"]*)\"$")
public void I_ve_launched_(String activityClassName)
throws Throwable {
String targetPackage = getInstrumentation().getTargetContext().getPackageName();
Class<? extends Activity> activityClass =
(Class<? extends Activity>) Class.forName(activityClassName);
currentActivity = launchActivity(targetPackage, activityClass, null);
}
@When("^User '(.+)' singIn with password '(.+)'$")
public void userLogin(String login, String password) {
mEmailEdt.perform(clearText());
mPassEdt.perform(clearText());
mEmailEdt.perform(ViewActions.typeText(login));
mPassEdt.perform(ViewActions.typeText(password));
mLoginBtn.perform(ViewActions.click());
}
@Then("^Check message about incorrect password")
public void checkTextOnScreen() {
onView(withText("Wrong pass")).check(matches(isDisplayed()));
}
Solution
I think you're missing some build.gradle
configuration parts like:
testApplicationId "cucumber.cukeulator.test"
testInstrumentationRunner "cucumber.cukeulator.test.Instrumentation"
Check this Cucumber
example build.gradle
configuration content: https://github.com/cucumber/cucumber-jvm/blob/master/examples/android/android-studio/Cukeulator/app/build.gradle
Hope it will help
Answered By - piotrek1543
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.