Add support to Espresso on Android #662

Closed
K76154 opened this Issue Jan 28, 2014 · 7 comments

Comments

Projects
None yet
4 participants
@K76154
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

This comment has been minimized.

Show comment
Hide comment
@SierraGolf

SierraGolf Jan 28, 2014

Contributor

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

Contributor

SierraGolf commented Jan 28, 2014

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

@K76154

This comment has been minimized.

Show comment
Hide comment
@K76154

K76154 Jan 29, 2014

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@SierraGolf

SierraGolf Jan 29, 2014

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.

Contributor

SierraGolf commented Jan 29, 2014

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

This comment has been minimized.

Show comment
Hide comment
@brasmusson

brasmusson Feb 12, 2014

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.

Contributor

brasmusson commented Feb 12, 2014

@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

This comment has been minimized.

Show comment
Hide comment
@K76154

K76154 Feb 13, 2014

Contributor

@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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@brasmusson

brasmusson Feb 13, 2014

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.

Contributor

brasmusson commented Feb 13, 2014

@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

This comment has been minimized.

Show comment
Hide comment
@friederbluemle

friederbluemle Feb 13, 2014

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.

Contributor

friederbluemle commented Feb 13, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment