Using: Cucumber-JVM with Android Instrumentation + Espresso).
Reference Github link: https://github.com/mfellner/cucumber-android for this. The simple sample works fine.
Problem with cucumber-jvm + android instrumentation: But in the sample in link, it uses ActivityInstrumentationTestCase2 which is deprecated. I would like to use @Rule - ActivityTestRule class as said by Google.
Here my question is: For using cucumber-jvm, I am using the CucumberInstrumentationCore instead of testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner".
So Android junit annotations like @Rule for ActivityTestRule is not parsed by CucumberInstrumentation. So Is it possible to overcome this problem?
Then is my decision to use cucumber-jvm + android instrumentation has to be reverted back. My question is not only for the deprecated class but globally is it good idea to go for cucumber-jvm + android instrumentation, as it can't use instrumentation features because of annotation parsing.
Your runner should inherit from Android JUnitRunner:
Pay attention to the super class been initialized at the end of onCreate.
Then, edit your defaultConfig in your build.grade file:
And finally, the steps definition class, which inherited from ActivityInstrumentationTestCase2 should look like:
The setUp function runs before each scenario, and launching the activity.
Globally, if it serves your needs I don't see any problem using it like so, both Cucumber annotations and the JUnit annotations can be parsed in this way.
I've created a sample project: github.com/Clutcha/EspressoCucumber