cucumber / cucumber-android

Android support for Cucumber-JVM
MIT License
135 stars 62 forks source link

No instrumentation registered! Must run under a registering instrumentation #76

Closed juanmendez closed 3 years ago

juanmendez commented 3 years ago

Hi, I try to run the Cukeulator demo, and each time I for instance run division.feature I get this error I was hoping to know if anyone else has faced this issue. Thank you.

java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
    at androidx.test.platform.app.InstrumentationRegistry.getInstrumentation(InstrumentationRegistry.java:45)
    at androidx.test.rule.ActivityTestRule.<init>(ActivityTestRule.java:148)
    at cucumber.cukeulator.test.CalculatorActivitySteps.<init>(CalculatorActivitySteps.java:39)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
    at io.cucumber.picocontainer.PicoFactory.getInstance(PicoFactory.java:42)
    at cucumber.runtime.java.ObjectFactoryLoader$ObjectFactoryAdapter.getInstance(ObjectFactoryLoader.java:157)
    at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:65)
    at cucumber.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:16)
    at cucumber.runner.TestStep.executeStep(TestStep.java:65)
    at cucumber.runner.TestStep.run(TestStep.java:50)
    at cucumber.runner.TestCase.run(TestCase.java:50)
    at cucumber.runner.Runner.runPickle(Runner.java:50)
    at cucumber.runtime.Runtime$1.run(Runtime.java:104)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)
    at cucumber.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:258)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at cucumber.runtime.Runtime.run(Runtime.java:101)
    at io.cucumber.core.cli.Main.run(Main.java:43)
    at io.cucumber.core.cli.Main.main(Main.java:14)
lsuski commented 3 years ago

As I see in stacktrace you are running it from cucumber command line interface, probably by clicking run next to scenario or feature. This will not work. You have to run it as instrumented android test

juanmendez commented 3 years ago

@lsuski sorry to bother with this, I am debugging as you mentioned..

image

This has modified running configurations to

image
juanmendez commented 3 years ago

@lsuski the read me documentation should be more specific about how to run tests. Reading from https://github.com/cucumber/cucumber-android/issues/78 what I ended up doing was run all tests using Android Instrumentation.

image

Once this took place, I was able to see all tests running

asbadarayani commented 1 year ago

As I see in stacktrace you are running it from cucumber command line interface, probably by clicking run next to scenario or feature. This will not work. You have to run it as instrumented android test

@lsuski , how to achieve this? I want to run by right click feature file and run as cucumber feature. If its not possible with current repo, is there any way to achieve it?

lsuski commented 1 year ago

It is possible but it's not responsibility of this repo but rather intellij plugin. To run particular scenario you have to pass instrumentation argument -e features <path to feature:line of scenario>

asbadarayani commented 1 year ago

Yeah, 100% agree that its not responsibility of repo.

Can you help me with it - In Android Studio, I want to right click and run feature file How can I do that?

passing instrumentation argument is when running test as instrumentation test. But I want to run teat as feature file

Help will be much appreciated, thanks in advance

lsuski commented 1 year ago

It's not possible in Android Studio right now. This requires creating new AS plugin. Anything you want to do in AS requires some plugin. In my company we created such plugin for internal usage but it's not opensourced. Maybe we will publish it

asbadarayani commented 1 year ago

Cool, Waiting for that plugin

Thanks for the answer

asbadarayani commented 1 year ago

Btw, which IntelliJ plugin can help me to run .feature file as cucumber run but not as instrument test run

lsuski commented 1 year ago

Cucumber for Java