xebia-functional / nine-cards-v2

An Open Source Android Launcher built with Scala on Android
http://www.9cards.io/
Other
182 stars 20 forks source link

UI test with Espresso #1249

Closed javipacheco closed 5 years ago

javipacheco commented 7 years ago

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

pedrovgs commented 7 years ago

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!

raulraja commented 7 years ago

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

pedrovgs commented 7 years ago

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.

pedrovgs commented 7 years ago

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.

raulraja commented 7 years ago

Feel free to replace whatever production code makes sense if the value added justifies the change. Other than that if you get stuck trying to get that in our current architecture @javielinux or myself should be able to provide direction as to how to overcome any issues you may not be familiar with.

On Thu, Mar 2, 2017, 11:12 AM Pedro Vicente Gómez Sánchez < notifications@github.com> wrote:

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 https://github.com/Karumi/KataScreenshotAndroid you can take a look at this repository if needed. Here https://github.com/Karumi/KataScreenshotAndroid/blob/master/app/src/androidTest/java/com/karumi/screenshot/MainActivityTest.java#L64 you can see how using mockito and a dependency injector we can configure the number of super heroes the Activity shows.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/47deg/nine-cards-v2/issues/1249#issuecomment-283612407, or mute the thread https://github.com/notifications/unsubscribe-auth/AAb4XKBmxKGw5c9-SkL8GrVgO6LcWlwNks5rhpYFgaJpZM4L1JfI .

pedrovgs commented 7 years ago

Ok!

soundslikeaplan