android test automation workshop
TRANSCRIPT
![Page 1: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/1.jpg)
Íntel Software and Services Group
Android: test automation workshopEduardo CarraraDeveloper Evangelist – Intel Developers Relations Division
![Page 2: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/2.jpg)
Intel Software and Services Group
#AndroidOnIntel
2
+EduardoCarraraDeAraujo
https://www.facebook.com/ducarrara
@DuCarrara
br.linkedin.com/in/eduardocarrara/
ecarrara-araujo
![Page 3: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/3.jpg)
Intel Software and Services Group 3
ObjectivePractice the usage of test automation tools available in the Android Framework through the following activities:
• Prepare the test environment for development and execution.
• Development of unit tests that run on the local JVM.
• Development of UI Tests with Espresso.
• Development of Cross Apps Tests with UI Automator.
• Running tests in the cloud with TestDroid.
![Page 4: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/4.jpg)
Intel Software and Services Group 4
Requirements
• Android Studio 1.3+
• Test Device with Android 4.0+
• SDK Version 23
• Build Tools 23.0.0
• AppCompat-v7 23.3.0
![Page 5: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/5.jpg)
Intel Software and Services Group 5
Base App - BeerWith• Simple demo app to help you keep track of
what have you been drinking and with who.
• https://github.com/ecarrara-araujo/beer-with
• If you want to follow the workshop just clone it and work on branch master.
• Check the branch ahead for the implementations:
• Imasters-android-devconf-tests-workshop
![Page 6: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/6.jpg)
Intel Software and Services Group
#1 – Creating your first Unit Test
6
![Page 7: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/7.jpg)
Intel Software and Services Group 7
#1 – Creating your first Unit Test
testCompile 'junit:junit:4.12'
• Add the Junit dependency to the app/build.gradle
![Page 8: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/8.jpg)
Intel Software and Services Group 8
#1 – Creating your first Unit Test
Create these directories.
![Page 9: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/9.jpg)
Intel Software and Services Group 9
#1 – Creating your first Unit Test
![Page 10: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/10.jpg)
Intel Software and Services Group 10
#1 – Creating your first Unit Test
![Page 11: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/11.jpg)
Intel Software and Services Group 11
#1 – Creating your first Unit Test
![Page 12: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/12.jpg)
Intel Software and Services Group 12
#1 – Creating your first Unit Test
public class UtilityTest {
@Test
public void testGetDateFormattedTime() throws Exception {
String expectedDateFormat = "yyyy, MMMM dd";
Calendar calendar = Calendar.getInstance();
calendar.set(2015, 4 - 1, 3); //20150403
String expectedResult = (new SimpleDateFormat(expectedDateFormat)).format(calendar.getTime());
String result = Utility.getDateFormattedTime(calendar, expectedDateFormat);
assertEquals("Date was not correctly formatted.", expectedResult, result);
// testing a second format to be sure
expectedDateFormat = "dd MM yyyy";
expectedResult = (new SimpleDateFormat(expectedDateFormat)).format(calendar.getTime());
result = Utility.getDateFormattedTime(calendar, expectedDateFormat);
assertEquals("Date was not correctly formatted.", expectedResult, result);
}
}
![Page 13: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/13.jpg)
Intel Software and Services Group 13
#1 – Creating your first Unit Test
$ ./gradlew testor
![Page 14: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/14.jpg)
Intel Software and Services Group 14
#1 – Creating your first Unit Test
or
\app\build\reports\tests\debug\index.html
![Page 15: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/15.jpg)
Intel Software and Services Group
#2 Testing the ui with espresso
15
![Page 16: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/16.jpg)
Intel Software and Services Group 16
#2 Testing the ui with espresso
• App/build.gradle
defaultConfig {
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
dependencies {
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
}
• ./build.gradle
allprojects {
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:23.0.0' } }
![Page 17: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/17.jpg)
Intel Software and Services Group 17
#2 Testing the ui with espresso
![Page 18: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/18.jpg)
Intel Software and Services Group 18
#2 Testing the ui with espresso
![Page 19: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/19.jpg)
Intel Software and Services Group 19
#2 Testing the ui with espresso
Here comes a whole lot of code…Check the file: BeerWith\app\src\androidTest\java\br\eng\ecarrara\beerwith\BeerWithMainActivityInstrumentationTest.java
![Page 20: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/20.jpg)
Intel Software and Services Group 20
#2 Testing the ui with espresso
or $ ./gradlew connectedCheck
![Page 21: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/21.jpg)
Intel Software and Services Group 21
#2 Testing the ui with espresso
or
app\build\reports\androidTests\connected\index.html
![Page 22: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/22.jpg)
Intel Software and Services Group
#3 CROss app Testing with UI Automator
22
![Page 23: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/23.jpg)
Intel Software and Services Group 23
#3 Cross app Testing with UI Automator
• App/build.gradle
defaultConfig {
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
• ./build.gradle
allprojects {
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:23.0.0' } }
dependecies {
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
androidTestCompile 'org.hamcrest:hamcrest-integration:1.3'
}
![Page 24: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/24.jpg)
Intel Software and Services Group 24
#3 Cross app Testing with UI Automator
![Page 25: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/25.jpg)
Intel Software and Services Group 25
#3 Cross app Testing with UI Automator
![Page 26: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/26.jpg)
Intel Software and Services Group 26
#3 Cross app Testing with UI Automator
Androidsdk/tools/uiautomatorviewer
![Page 27: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/27.jpg)
Intel Software and Services Group 27
#3 Cross app Testing with UI Automator
Here comes a whole lot of code…Check the file: BeerWith\app\src\androidTest\java\br\eng\ecarrara\beerwith\AddingBeerWithCompleteTestFlow.java
![Page 28: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/28.jpg)
Intel Software and Services Group 28
#3 Cross app Testing with UI Automator
or $ ./gradlew connectedCheck
![Page 29: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/29.jpg)
Intel Software and Services Group 29
or
![Page 30: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/30.jpg)
Intel Software and Services Group 30
![Page 31: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/31.jpg)
Intel Software and Services Group 31
![Page 32: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/32.jpg)
Intel Software and Services Group 32
![Page 33: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/33.jpg)
Intel Software and Services Group 33
![Page 34: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/34.jpg)
Intel Software and Services Group 34
![Page 35: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/35.jpg)
Intel Information Technology
What is next?
35
• Follow the guide and automate your tests!
• How to integrate continous integration and delivery with Android?
• Code Coverage
• Mocking
![Page 36: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/36.jpg)
Intel Software and Services Group 36
Intel Developer Zone
https://software.intel.com/en-us/android/app-testing
![Page 37: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/37.jpg)
Intel Software and Services Group
Thanks!
37
+EduardoCarraraDeAraujo
https://www.facebook.com/ducarrara
@DuCarrara
br.linkedin.com/in/eduardocarrara/
ecarrara-araujo/vilibra
![Page 38: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/38.jpg)
Intel Software and Services Group 38
References
• Android Testing: https://developer.android.com/tools/testing/testing_android.html
• Android Unit Testing Support: http://tools.android.com/tech-docs/unit-testing-support
• UI Testing: https://developer.android.com/training/testing/ui-testing/index.html
• Android Testing Support Library: https://developer.android.com/tools/testing-support-library
• Android Instrumentation: http://developer.android.com/tools/testing/testing_android.html#Instrumentation
• Junit: http://junit.org
• Testdroid: http://testdroid.com
• Intel App Testing Page: https://software.intel.com/en-us/android/app-testing
![Page 39: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/39.jpg)
Intel Software and Services Group 39
References
• Codelab Android Studio Testing: https://io2015codelabs.appspot.com/codelabs/android-studio-testing#1
• Android Testing Blueprints: https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint
• Testing on Android by Vincent Brison: http://vincentbrison.com/2015/08/05/testing-on-android-part1-a-practical-approach/
• Android Developers Unit Testing Training: https://developer.android.com/training/testing/unit-testing/index.html
• Android Testing Samples: https://github.com/googlesamples/android-testing/
• G+ Community: https://plus.google.com/communities/10515313437206298596
• Stack Overflow: http://stackoverflow.com/questions/tagged/android-testing
![Page 40: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/40.jpg)
Intel Software and Services Group 40
References
• Espresso v2 Cheat Sheet - https://code.google.com/p/android-test-kit/wiki/EspressoV2CheatSheet
![Page 41: Android Test Automation Workshop](https://reader034.vdocuments.site/reader034/viewer/2022051523/589cbeeb1a28ab8b018b541f/html5/thumbnails/41.jpg)
Placeholder Footer Copy / BU Logo or Name Goes Here