Skip to content
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

Add support to Espresso on Android #662

Closed
K76154 opened this issue Jan 28, 2014 · 8 comments · Fixed by #667
Closed

Add support to Espresso on Android #662

K76154 opened this issue Jan 28, 2014 · 8 comments · Fixed by #667

Comments

@K76154
Copy link
Contributor

K76154 commented Jan 28, 2014

Google released a new UI automation framework called Espresso, which I think is much better than Robotium after using it for few months. It will be great if cucumber-android can also support it. I've tried and it's actually a very simple change. Just make CucumberInstrumentation to extend Espresso's GoogleInstrumentationTestRunner, and move super.onCreate() call from the first line in onCreate() to the last line, and remove the start() in onCreate().

We may not want to have Espresso dependencies if the user isn't using it, so maybe the best way to do it is to create another Instrumentation like CucumberEspressoInstrumentation.

@SierraGolf
Copy link
Contributor

I was thinking about that already. I like your idea. Can you provide a pull request?

@K76154
Copy link
Contributor Author

K76154 commented Jan 29, 2014

I really want to, and that's a really easy two liner change. I have that done on my local machine. However, my company has strict policy on contribution to open source projects, so I can't without first going through the complicated review process. So hopefully someone else can do that. It's really quite simple, just two lines of code change.

@SierraGolf
Copy link
Contributor

Why don’t you do it on your free time?

I really want to, and that's a really easy two liner change. I have that done on my local machine. However, my company has strict policy on contribution to open source projects, so I can't without first going through the complicated review process. So hopefully someone else can do that. It's really quite simple, just two lines of code change.

@brasmusson
Copy link
Contributor

@SierraGolf @K76154 I took a stab at enabling Espresso support in #667 (without introducing a dependency on Espresso, since it does not look officially available through Maven). Comments are more than welcome.

@K76154
Copy link
Contributor Author

K76154 commented Feb 13, 2014

@brasmusson That's exactly what I was thinking. Just don't understand what those public static final fields are for. Thanks for making the pull request.

@brasmusson
Copy link
Contributor

@K76154 I don't understand the public fields either. CucumberInstrumentation.TAG is used in the before and after hooks in example/andriod-test. There might be some advantage of being able to group logs from the step definitions in the same tag as the other logs from Cucumber-Android, but both CucumberInstrumentation.REPORT_VALUE_ID and CucumberInstrumentation.REPORT_KEY_NUM_TOTAL looks as if they should have been private.

I kept them as public in CucumberInstrumenatation just to be very sure not to break someone current use of Cucumber-Android. Maybe especially CucumberInstrumentation.REPORT_VALUE_ID and CucumberInstrumentation.REPORT_KEY_NUM_TOTAL should at least be made deprecated in the PR.

@friederbluemle
Copy link
Contributor

Take a look at the source of Instrumentation.java and InstrumentationTestRunner.java to understand the existence of these fields.
Unfortunately InstrumentationTestRunner is not designed for inheritance, that is why CucumberInstrumentation had to copy a lot of code from this class. Since copying code and making very minor modifications is even worse than just copying code 1:1, the code went into CucumberInstrumentation as is. Plus, for an external user, CucumberInstrumentation should feel and behave just like the real InstrumentationTestRunner.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants