-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting error: cucumber.runtime.CucumberException: No CucumberOptions annotation #3
Comments
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. |
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... |
That is a different problem, maybe CucumberTestCase.java is not part of your test package. |
Sure, let me upload it to a repo and send you the link. |
There are a few Cucumber problems in your example project but I made it run: 1.- Location of Cucumber runner and options classes
2.- The Activity tested in step definitions
Let me know if you made it work with these fixes. |
Thanks, these solved my issues. I'm successfully able to run the tests now. |
He @sebaslogen, |
java.lang.RuntimeException: Exception thrown in onCreate() of ComponentInfo{com..mobile.android.test/com..mobile.***.cucumber.runner.CucumberTestRunner}: cucumber.runtime.CucumberException: No CucumberOptions annotation |
Hi @moenterazi, If you still can't figure it out, share your code online and I can take a look at it. |
@sebaslogen thanks sebas. The issue is resolved now. |
@moenterazi I got this message quite fast but I was away on holidays. I'm glad it works now :) |
@sebaslogen... getting the following: In my stepdefinition class i have a call to some other already written tests with @test annotations in espresso. |
@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 |
@sebaslogen looks like i'm not defining the location for the feature file and steps file properly. |
@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. |
@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. VIEW: and added what you had for build.gradle of the app I added what you added. Here are the content of the files: package com._.mobile._.cucumber.conf; import cucumber.api.CucumberOptions; /**
CucumberTestRunner.java package com._.mobile._.cucumber.runner; import android.os.Bundle; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; /**
public class CucumberTestRunner extends android.support.test.runner.AndroidJUnitRunner {
} CucumberTestRunner.java package com._.mobile._.cucumber.runner; import android.os.Bundle; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; /**
public class CucumberTestRunner extends android.support.test.runner.AndroidJUnitRunner {
} |
@moenterazi did you modify your app/build.gradle to point to the cucumber test runner that you posted? Also in |
@sebaslogen yes to the 1st question. second: changed it to src/main/assets/features |
still getting no test error |
@sebaslogen can i have the two of these runners together? |
here is my gradle changes
// androidTestCompile 'info.cukes:cucumber-testng:1.2.4' |
@moenterazi |
@sebaslogen $ adb shell am instrument -w -r -e tags @managePayees -e debug false com._.mobile.android.test/com._.mobile.***.cucumber.runner.CucumberTestRunner |
@sebaslogen com.android.builder.testing.ConnectedDevice > No tests found.[SM-G900W8 - 6.0.1] FAILED FAILURE: Build failed with an exception.
BUILD FAILED Total time: 56.152 secs |
@moenterazi check that you have a feature file in /app/src/androidTest/assets/features/ with:
And on the Step definitions java file inside package 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"). |
@sebaslogen still the same |
@sebaslogen if I try to run the feature file this is what I get: Testing started at 7:02 PM ... 1 Scenarios (1 undefined) Undefined step: Given Text for step You can implement missing steps with the snippets below: @given("^Text for step$") |
@moenterazi Perfect, that means it's running because it recognized the feature and scenario, you are simply getting back the exception that you throw |
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. |
@moenterazi it's reading Alternative you can paste upload your feature file and step definitions file and maybe I can stop the syntax error. |
other ones were commented out. Feature: Some text description @managePayees
|
@sebaslogen can we share things privately? |
@moenterazi, yes, you can write me at gmail, my user is the same as in github. |
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! |
@Auronake no, without the full code I wasn't able to figure out what was the difference between his project and this repository. Good luck. |
@sebaslogen ok thanks for the reply :) i'll try |
@sebaslogen when i am playing around with your project https://github.com/sebaslogen/CleanGUITestArchitecture.git following error displayed in the project Running dex as a separate process. To run dex in process, the Gradle daemon needs a larger heap. warning: Ignoring InnerClasses attribute for an anonymous inner class :app:transformClassesWithDexForDebugAndroidTest FAILED FAILURE: Build failed with an exception.
BUILD FAILED please provide me some direction to fix the issue for web view testing thanks |
@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 |
@sebaslogen thanks for spontaneous reply, I tried everything to my knowledge. if you can update your repository (https://github.com/sebaslogen/CleanGUITestArchitecture.git) with thanks Vijay |
@sebaslogenI managed the resolved the issue by adding following info to build.gradle |
@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. |
I am getting this error: can anyone please help me here is my error stack trace Here is my runner file: import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @RunWith(Cucumber.class) } Here is my step definition: import core.ApexBaseTest; public class LoginStep extends ApexBaseTest implements EcommerceConstants{
} Feature file: Feature: Ecommerce Application Test Scenario Outline: Validate Ecommerce Login Page Test Given ecomm user enters the url Examples: |
Hey, I've created a sample project based on your example here and now I'm getting the above mentioned exception every time I try to run my test (HelloWorldSteps.java). I would greatly appreciate it if you could tell me what I'm doing wrong. I've attached the relevant classes below. Alternatively, I can also upload my project if you need more information. Let me know. :)
Instrumentation class
@CucumberOptions marker class
Step Definition Class
.feature file placed in /src/androidTest/assets/features
The text was updated successfully, but these errors were encountered: