xebia-functional/nine-cards-v2

UI test with Espresso

javipacheco opened this issue · 6 comments

We should found the best way to create tests for UI using Espresso. This issue is for investigating about how we can generate the tests

Great idea! But before to start with this task, I'd evaluate if using a different approach like screenshot testing is going to be better for this project. As this is an open source project where the UI changes are really important using an approach based on screenshot could really improve the quality of your external and internal contributions. You can compare how the same project tested with screenshot testing or espresso reduces the number of tests needed and also creates an awesome history for your UI changes. In addition, any change in the code changing the color or the position of just one pixel will break the build until a UI designer or any member of the team validates the change. I'm sure this is something @jorgegalindocruces is going to love! 😄

The main issue you are going to find is that this framework is based on two Gradle tasks I'm not sure you can invoke from sbt.

I'd really like to collaborate, if I can help, just let me know!

@pedrovgs We should be able to invoke gradle from within sbt as a process. Also if the gradle tasks are just calling other Java APIs we can just rewrite those in sbt. If you think putting a small POC of screenshot testing is not a lot of work we'd love this contribution.

It's not so hard and I'd really like to contribute with regular UI tests or screenshot tests. The problem is that to be effective I need to replace part of the production code using a test double or using this technique could be really difficult.

Remember that I can't get an instance of an Activity without initializing the Activity lifecycle so depending on the project architecture we will be able to easily simulate different scenarios or not.

Here you can take a look at this repository if needed. Here you can see how using mockito and a dependency injector we can configure the number of super heroes the Activity shows.

Ok!

soundslikeaplan