Comments (44)
There are a few Cucumber problems in your example project but I made it run:
1.- Location of Cucumber runner and options classes
- The last error that you mentioned "No CucumberOptions annotation" is thrown because the CucumberTestCase class is in package 'com.aashreys.cucumberplayground', if you put the class in any sub-package the problem is solved, for example in 'com.aashreys.cucumberplayground.test'
- The same problem happens with the CucumberTestRunner class, it has to be in a sub-package, for example in 'com.aashreys.cucumberplayground.runner' (remember to modify the build.gradle accordingly)
2.- The Activity tested in step definitions
- The constructor of HelloWorldSteps class in your example has to be changed to: public HelloWorldSteps() {super(MainActivity.class);}
- Your app activity has to extend from Activity, instead of AppCompatActivity, otherwise a java.lang.IncompatibleClassChangeError exception is thrown. Alternatively, the dependencies that come bundled with Espresso have to be excluded, see this answer http://stackoverflow.com/a/34645356/5250468
Let me know if you made it work with these fixes.
from cleanguitestarchitecture.
The Cucumber error message is not very helpful but looking at your code there is one thing that is not allowed in Cucumber and maybe it's the root of your problem:
Step definitions annotated with @Given/@When/@Then/@and can not be duplicated and the keywords at the beginning of the sentences are equivalent and interchangeable, so you can annotate a method with @given("some exact text") and then use it in the feature files as 'Given some exact text' or 'And some exact text' and both will work.
Now with this cucumber rule for the @Given/@When/@Then/@and keywords, you can see in the sample code that the @given("^the text is "(.+)"$") and @then("^the text is "(.+)"$") annotations are exactly the same for Cucumber and therefore invalid.
from cleanguitestarchitecture.
Oh alright. I've modified my feature file above and in my project to have different texts. My problem however is that Cucumber can't find the @CucumberOptions annotations and hence is unable to locate my scenario entirely. Here's the logcat if you need more info
01-26 12:46:37.004 11545-11545/? E/MonitoringInstrumentation: Exception encountered by: Thread[main,5,main]. Dumping thread state to outputs and pining for the fjords.
java.lang.RuntimeException: Exception thrown in onCreate() of ComponentInfo{com.aashreys.cucumberplayground.test/com.aashreys.cucumberplayground.CucumberTestRunner}: cucumber.runtime.CucumberException: No CucumberOptions annotation
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4547)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: cucumber.runtime.CucumberException: No CucumberOptions annotation
at cucumber.runtime.android.CucumberExecutor.createRuntimeOptions(CucumberExecutor.java:156)
at cucumber.runtime.android.CucumberExecutor.<init>(CucumberExecutor.java:88)
at cucumber.api.android.CucumberInstrumentationCore.create(CucumberInstrumentationCore.java:70)
at com.aashreys.cucumberplayground.CucumberTestRunner.onCreate(CucumberTestRunner.java:20)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4544)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
01-26 12:46:37.006 11545-11545/? E/THREAD_STATE: Thread[Instr: com.aashreys.cucumberplayground.CucumberTestRunner,5,main]
java.lang.Object.wait(Native Method)
android.app.Instrumentation$Idler.waitForIdle(Instrumentation.java:1939)
android.app.Instrumentation.waitForIdleSync(Instrumentation.java:338)
com.aashreys.cucumberplayground.CucumberTestRunner.onStart(CucumberTestRunner.java:25)
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853)
01-26 12:46:37.006 11545-11545/? E/MonitoringInstrumentation: Dying now...
from cleanguitestarchitecture.
That is a different problem, maybe CucumberTestCase.java is not part of your test package.
If you put the rest of the code online maybe I can see the source of the problem.
from cleanguitestarchitecture.
Sure, let me upload it to a repo and send you the link.
from cleanguitestarchitecture.
Here: https://github.com/aashrey99/CucumberPlayground
from cleanguitestarchitecture.
Thanks, these solved my issues. I'm successfully able to run the tests now.
from cleanguitestarchitecture.
He @sebaslogen,
Have setup the same way you have on your project but keep getting the No CucumberOptions annotation
from cleanguitestarchitecture.
java.lang.RuntimeException: Exception thrown in onCreate() of ComponentInfo{com..mobile.android.test/com..mobile.***.cucumber.runner.CucumberTestRunner}: cucumber.runtime.CucumberException: No CucumberOptions annotation
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6310)
at android.app.ActivityThread.access$1800(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230
from cleanguitestarchitecture.
Hi @moenterazi,
The usual reason for this problem is that the java file with CucumberOptions is not in the right path/package. See this comment: #3 (comment)
If you still can't figure it out, share your code online and I can take a look at it.
from cleanguitestarchitecture.
@sebaslogen thanks sebas. The issue is resolved now.
is there a way to contact you faster... through email?
from cleanguitestarchitecture.
@moenterazi I got this message quite fast but I was away on holidays. I'm glad it works now :)
from cleanguitestarchitecture.
@sebaslogen... getting the following:
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @test annotations).
In my stepdefinition class i have a call to some other already written tests with @test annotations in espresso.
from cleanguitestarchitecture.
@moenterazi if you look at the examples in StepDefinitions you don't have to tag anything with @test, you need to create methods with the @given("") annotation to define steps and use these steps in your feature file.
The error you get seems like there is no feature file in the assets folder or the test case in the feature file doesn't have any tag from the ones you select in the CucumberOptions
from cleanguitestarchitecture.
@sebaslogen looks like i'm not defining the location for the feature file and steps file properly.
from cleanguitestarchitecture.
@moenterazi if you still have problems you can share your implementation of the step definitions, feature file and cucumber options like the original reporter of the problem and maybe I can help you more.
from cleanguitestarchitecture.
@sebaslogen looks like my testrunner is not being detected. because when it's commented it's not making any different and still cannot find tests.
So what i'm doing is that i'm integrating cucumber with a current android app and unable share the code online.
What i've done with directory structure is this:
in android Studio.
VIEW:
app->java->com.x.x.androidTest->original-espresso-test
->cucumber->conf->CucumberTestCase.java (contains@options - ->cucumber->runner->CucumberTestRunner.java
->cucumber->steps->StepDefinitions.java
and added what you had for build.gradle of the app I added what you added.
Here are the content of the files:
CucumberTestCase.java
package com._.mobile._.cucumber.conf;
import cucumber.api.CucumberOptions;
/**
- Glue for Cucumber
/
@CucumberOptions(features = "src/androidTest/assets/features",//"com..mobile..cucumber.conf", // Test scenarios
glue = {"com.**.mobile.android.cucumber.steps"}, // Steps definitions
tags={"@sometest"}
)
class CucumberTestCase {
}
CucumberTestRunner.java
package com._.mobile._.cucumber.runner;
import android.os.Bundle;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.android.CucumberInstrumentationCore;
//import cucumber.api..AbstractTestNGCucumberTests;
/**
- Used in build.gradle/testInstrumentationRunner to run Cucumber tests
- 'testInstrumentationRunner' variable in build.gradle has to point to this package
*/
public class CucumberTestRunner extends android.support.test.runner.AndroidJUnitRunner {
public static final String TAG = CucumberTestRunner.class.getSimpleName();
/**
* This is the item Cucumber uses to identify the tags parameter, see method
* cucumber-android-1.2.2.jar\cucumber\runtime\android\Arguments.class @ getCucumberOptionsString()
*/
private static final String CUCUMBER_TAGS_KEY = "tags";
private final CucumberInstrumentationCore instrumentationCore = new CucumberInstrumentationCore(this);
@Override
public void onCreate(final Bundle bundle) {
super.onCreate(bundle);
final String tags = "";
if (!tags.isEmpty()) {
bundle.putString(CUCUMBER_TAGS_KEY, tags.replaceAll(",", "--").replaceAll("\\s",""));
}
instrumentationCore.create(bundle);
}
@Override
public void onStart() {
waitForIdleSync();
instrumentationCore.start();
}
}
CucumberTestRunner.java
package com._.mobile._.cucumber.runner;
import android.os.Bundle;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.android.CucumberInstrumentationCore;
//import cucumber.api..AbstractTestNGCucumberTests;
/**
- Used in build.gradle/testInstrumentationRunner to run Cucumber tests
- 'testInstrumentationRunner' variable in build.gradle has to point to this package
*/
public class CucumberTestRunner extends android.support.test.runner.AndroidJUnitRunner {
public static final String TAG = CucumberTestRunner.class.getSimpleName();
/**
* This is the item Cucumber uses to identify the tags parameter, see method
* cucumber-android-1.2.2.jar\cucumber\runtime\android\Arguments.class @ getCucumberOptionsString()
*/
private static final String CUCUMBER_TAGS_KEY = "tags";
private final CucumberInstrumentationCore instrumentationCore = new CucumberInstrumentationCore(this);
@Override
public void onCreate(final Bundle bundle) {
super.onCreate(bundle);
final String tags = "";
if (!tags.isEmpty()) {
bundle.putString(CUCUMBER_TAGS_KEY, tags.replaceAll(",", "--").replaceAll("\\s",""));
}
instrumentationCore.create(bundle);
}
@Override
public void onStart() {
waitForIdleSync();
instrumentationCore.start();
}
}
from cleanguitestarchitecture.
@moenterazi did you modify your app/build.gradle to point to the cucumber test runner that you posted?
testInstrumentationRunner "com..mobile..cucumber.runner.CucumberTestRunner"
Also in @CucumberOptions(features = "src/androidTest/assets/features",
you should point only to features
folder because the folder src/androidTest
doesn't exist at runtime and the folder assets is where the Cucumber is going to start looking for features by default.
from cleanguitestarchitecture.
@sebaslogen yes to the 1st question.
second: changed it to src/main/assets/features
from cleanguitestarchitecture.
still getting no test error
from cleanguitestarchitecture.
@sebaslogen can i have the two of these runners together?
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "com.rbc.mobile.bud.cucumber.runner.CucumberTestRunner"
from cleanguitestarchitecture.
here is my gradle changes
//Espresso
androidTestCompile('com.android.support.test:runner:0.5') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
androidTestCompile 'com.android.support:design:23.3.0'
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude module: 'support-annotations'
}
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2') {
exclude module: 'support-annotations'
exclude module: 'support-v4'
exclude module: 'recyclerview-v7'
}
// Cucumber
androidTestCompile('info.cukes:cucumber-android:1.2.4') {
exclude module: 'cucumber-jvm-deps'
}
androidTestCompile('info.cukes:cucumber-picocontainer:1.2.4') {
exclude module: 'cucumber-jvm-deps'
}
androidTestCompile 'info.cukes:cucumber-jvm-deps:1.0.3'
// androidTestCompile 'info.cukes:cucumber-testng:1.2.4'
from cleanguitestarchitecture.
@moenterazi second: changed it to src/main/assets/features
I meant exactly the opposite, to change your CucumberTestCase.java file to @CucumberOptions(features = "features",
exactly like the example in this project
from cleanguitestarchitecture.
@sebaslogen
ing tests
$ adb shell am instrument -w -r -e tags @managePayees -e debug false com._.mobile.android.test/com._.mobile.***.cucumber.runner.CucumberTestRunner
Client not ready yet..
Started running tests
Test running failed: Instrumentation run failed due to 'cucumber.runtime.CucumberException'
Empty test suite.
from cleanguitestarchitecture.
@sebaslogen
:app:connectedAutoSignInDebugAndroidTest
Tests on SM-G900W8 - 6.0.1 failed: Instrumentation run failed due to 'cucumber.runtime.CucumberException'
com.android.builder.testing.ConnectedDevice > No tests found.[SM-G900W8 - 6.0.1] FAILED
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @test annotations).
:app:connectedAutoSignInDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
-
What went wrong:
Execution failed for task ':app:connectedAutoSignInDebugAndroidTest'.There were failing tests. See the report at: file:///Users/********/Android-UI-Bud/app/build/reports/androidTests/connected/flavors/AUTOSIGNIN/index.html
-
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 56.152 secs
from cleanguitestarchitecture.
@moenterazi check that you have a feature file in /app/src/androidTest/assets/features/ with:
Feature: Some text description
@managePayees
Scenario: Some text description
Given Text for step
And on the Step definitions java file inside package com.**.mobile.android.cucumber.steps
you have:
@Given("Text for step") public void my_step_name() {}
If this is the case, try with one single feature, 1 scenario and 1 very simple step, then make sure the syntaxis is correct. I remember having a weird fail once because the feature text was very bad formatted (e.g. having a step without any text for the step, so a line with only "Given").
from cleanguitestarchitecture.
@sebaslogen still the same
from cleanguitestarchitecture.
@sebaslogen if I try to run the feature file this is what I get:
Testing started at 7:02 PM ...
1 Scenarios (1 undefined)
1 Steps (1 undefined)
0m0.000s
Undefined step: Given Text for step
You can implement missing steps with the snippets below:
@given("^Text for step$")
public void text_for_step() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
from cleanguitestarchitecture.
@moenterazi Perfect, that means it's running because it recognized the feature and scenario, you are simply getting back the exception that you throw new PendingException()
, now implement the code inside public void text_for_step()
and you can have a successful test scenario executed.
from cleanguitestarchitecture.
But i don't think it's reading the steps that i provided. It seems to be suggesting a sample step that need to be created like.
from cleanguitestarchitecture.
@moenterazi it's reading text_for_step()
, so if it's reading that step but not the other ones you created it means there is a problem (my guess it's a syntax problem) in the other steps. My suggestion is to take the feature and step that works @Given("^Text for step$")
and start modifying it in small steps until it looks like the one you created before, I imagine at some point during the modification process you're gonna see the fail happening and you'll know exactly where you're feature file or step definition is broken.
Alternative you can paste upload your feature file and step definitions file and maybe I can stop the syntax error.
from cleanguitestarchitecture.
other ones were commented out.
Feature: Some text description
@managePayees
Scenario: Some text description
Given Text for step
@Given("^Text for step$") public void my_step_name() {}
from cleanguitestarchitecture.
@sebaslogen can we share things privately?
from cleanguitestarchitecture.
@moenterazi, yes, you can write me at gmail, my user is the same as in github.
from cleanguitestarchitecture.
Hello @sebaslogen, i try to execute tests in the same way of this discussion and i fail in the same step
Have you resolved the problem with @moenterazi ? If yes, can you write it here ? Thanks!
from cleanguitestarchitecture.
@Auronake no, without the full code I wasn't able to figure out what was the difference between his project and this repository.
I would recommend to start by executing the code in this repo in your computer and then copy/migrate to your project until you have one single feature with one scenario and one step running.
Good luck.
from cleanguitestarchitecture.
@sebaslogen ok thanks for the reply :) i'll try
from cleanguitestarchitecture.
@sebaslogen when i am playing around with your project https://github.com/sebaslogen/CleanGUITestArchitecture.git
I added an entry to gradle file for web view testing
androidTestCompile('com.android.support.test.espresso:espresso-web:2.2.2') {
exclude group: 'com.android.support'
}
following error displayed in the project
:app:transformClassesWithDexForDebugAndroidTest
Running dex as a separate process.
To run dex in process, the Gradle daemon needs a larger heap.
It currently has 1024 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.ccil.cowan.tagsoup.Parser$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/thirdparty/publicsuffix/PublicSuffixPatterns;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/thirdparty/publicsuffix/PublicSuffixPatterns;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:591)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:546)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:528)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
:app:transformClassesWithDexForDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebugAndroidTest'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
please provide me some direction to fix the issue for web view testing
thanks
Vijay
from cleanguitestarchitecture.
@maravij a quick Google search points to a problem of duplicated dependencies that you include with the espresso-web: http://stackoverflow.com/questions/22468700/unexpected-top-level-exception-com-android-dex-dexexception-multiple-dex-files#26940654
from cleanguitestarchitecture.
@sebaslogen thanks for spontaneous reply, I tried everything to my knowledge. if you can update your repository (https://github.com/sebaslogen/CleanGUITestArchitecture.git) with
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
it would be great
thanks
Vijay
from cleanguitestarchitecture.
@sebaslogenI managed the resolved the issue by adding following info to build.gradle
androidTestCompile('info.cukes:cucumber-android:1.2.4') {
exclude group: 'com.google.guava'
exclude module: 'cucumber-jvm-deps'
}
from cleanguitestarchitecture.
@maravij 💯 👌! Well done for finding the duplicated dependency between those two libraries.
This demo project doesn't use espresso-web so if I add the dependency to build.gradle, some people may think it's mandatory to use it for any kind Espresso tests. Imho, the best you can do is write a question and answer in StackOverflow about the problem of combining com.android.support.test.espresso:espresso-web with info.cukes:cucumber-android, it will be very useful.
from cleanguitestarchitecture.
I am getting this error: can anyone please help me here is my error stack trace
cucumber.api.PendingException: TODO: implement me
at cucumber.runtime.junit.JUnitReporter.addFailure(JUnitReporter.java:150)
at cucumber.runtime.junit.JUnitReporter.addFailureOrIgnoreStep(JUnitReporter.java:138)
at cucumber.runtime.junit.JUnitReporter.result(JUnitReporter.java:98)
at cucumber.runtime.Runtime.runStep(Runtime.java:282)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at cucumber.runtime.junit.ExamplesRunner.run(ExamplesRunner.java:59)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at cucumber.runtime.junit.ScenarioOutlineRunner.run(ScenarioOutlineRunner.java:53)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Here is my runner file:
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "/Users/amruthapenigalapati/eclipse-workspace/corejava/src/Basic_java/CucumberWithJunit/src/test/java/features/Login.feature", //the path of the feature files
glue={"stepDefinitions.LoginStep"}, //the path of the step definition files
plugin = {"pretty","html:test-outout", "json:json_output/cucumber.json", "junit:junit_xml/cucumber.xml"}, //to generate different types of reporting
monochrome = true, //display the console output in a proper readable format
strict = true //it will check if any step is not defined in step definition file
//dryRun = false //to check the mapping is proper between feature file and step def file
)
public class TestRunner {
}
Here is my step definition:
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import core.ApexBaseTest;
import core.EcommerceConstants;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class LoginStep extends ApexBaseTest implements EcommerceConstants{
static WebDriver driver;
@given("^ecomm user enters the url$")
public static void ecomm_user_enters_the_url() throws Throwable {
ApexBaseTest.setup();
Assert.assertEquals("Welcome to Ez Shop Online" , TITLE);
driver.findElement(By.linkText("ACCOUNT")).click();
}
@When("^ecomm user enters the login details \"([^\"]*)\" and \"([^\"]*)\"$")
public static void ecomm_user_enters_the_login_details(String UserName, String Password) throws Throwable {
driver.findElement(By.name(EMAIL_NAME_LOCATOR)).sendKeys(UserName);
driver.findElement(By.name(PWD_NAME_LOCATOR)).sendKeys(Password);
driver.findElement(By.xpath("/html/body/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[4]/td[2]/form/table/tbody/tr[5]/td/a/div")).click();
}
@Then("^user logs in successfully$")
public void user_logs_in_successfully() throws Throwable {
Assert.assertEquals("You have Logged In successfully.",TITLE2);
}
}
Feature file:
Feature: Ecommerce Application Test
Scenario Outline: Validate Ecommerce Login Page Test
Given ecomm user enters the url
When ecomm user enters the login details "" and ""
Then user logs in successfully
Examples:
| UserName | Password |
| [email protected] | Welcome@123 |
|[email protected] | chitra121 |
from cleanguitestarchitecture.
@aranip see my answer to your questions in #27
from cleanguitestarchitecture.
Related Issues (20)
- Questions : no test were found HOT 2
- Gradle Tasks failed after execution HOT 2
- Run specific feature HOT 1
- Cucumber reports are not generated HOT 7
- Undefined step(s) returned when executing feature file HOT 14
- Exception while taking the screenshot HOT 2
- Running feature seems to fail. HOT 3
- Only works for Android 5.1 HOT 3
- How to run multi step definitions file HOT 6
- Question : Reset app state between scenario HOT 1
- Getting "cucumber.runtime.CucumberException" error on running the "StepDefinitions" HOT 19
- Spoon report and screenshots HOT 3
- Getting error "java.lang.AbstractMethodError at cucumber.runtime.UndefinedStepsTracker" HOT 1
- Unable to find element in a webview using onWebView method after SDK 27 update HOT 1
- Getting pending exception when i run my runner file in cucumber HOT 2
- Issue java.lang.NoSuchMethodError: com.aventstack.extentreports.reporter.ExtentHtmlReporter.loadXMLConfig(Ljava/io/File;)
- Cucumber Tests to be run in JMeter. Getting "Could not initialize class io.cucumber.core.options.PluginOption" HOT 2
- Trace -- java.lang.NoSuchMethodError: io.cucumber.tagexpressions.TagExpressionParser: method 'void <init>()' not found
- JENIKS: GRADLE: TESTNG: CUCUMBER FEATURE File: testrunner is faling on jekins pipeline only HOT 2
- plugin in Cucumber runner class are showing attribute undefined. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cleanguitestarchitecture.