SlideShare a Scribd company logo
1 of 95
Download to read offline
MOBILE AGILE
Godfrey Nolan
AGENDA
Android (am)
iOS (pm)
ANDROID AGENDA
Why??
Unit, UI and API testing 101
Calculator Example
More Tools - FIRST
ETA Detroit
jUnit Testing
Espresso
Postman / Newman
Jenkins
IOS AGENDA
Why??
Unit, UI and API testing 101
Calculator Example
No really why?? (FIRST)
ETA Detroit
XCTest
XCUI
Postman / Newman
Jenkins
FOLLOW ALONG
git clone http://github.com/godfreynolan/CodeCraftsman
WHY
Catch more mistakes
Confidently make more changes
Built in regression testing
Extend the life of your codebase
UNIT TESTING INTRO
public double add(double firstOperand, double secondOperand) {
return firstOperand + secondOperand;
}
@Test
public void calculator_CorrectAdd_ReturnsTrue() {
assertEquals(7, add(3,4);
}
@Test
public void calculator_CorrectAdd_ReturnsTrue() {
assertEquals("Addition is broken", 7, add(3,4);
}
dependencies {
// Unit testing dependencies.
testCompile 'junit:junit:4.12'
}
UNIT TESTING 101
Command line
Setup and Teardown
Assertions
Parameters
Code Coverage
C:UsersgodfreyAndroidStudioProjectsBasicSample>gradlew test --continue
Downloading https://services.gradle.org/distributions/gradle-2.2.1-all.zip
................................................................................
..................................................
Unzipping C:Usersgodfrey.gradlewrapperdistsgradle-2.2.1-all6dibv5rcnnqlfbq9klf8imrndn
Download https://jcenter.bintray.com/com/google/guava/guava/17.0/guava-17.0.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/24.2.3/lint-api-24.2.3.j
Download https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.jar
Download https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombo
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
.
.
.
:app:compileReleaseUnitTestSources
:app:assembleReleaseUnitTest
:app:testRelease
:app:test
BUILD SUCCESSFUL
Total time: 3 mins 57.013 secs
public class CalculatorTest {
private Calculator mCalculator;
@Before
public void setUp() {
mCalculator = new Calculator();
}
@Test
public void calculator_CorrectAdd_ReturnsTrue() {
double resultAdd = mCalculator.add(3, 4);
assertEquals(7, resultAdd,0);
}
@After
public void tearDown() {
mCalculator = null;
}
}
UNIT TESTING 101
assertEquals
assertTrue
assertFalse
assertNull
assertNotNull
assertSame
assertNotSame
assertThat
fail
@RunWith(Parameterized.class)
public class CalculatorParamTest {
private int mOperandOne, mOperandTwo, mExpectedResult;
private Calculator mCalculator;
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{3, 4, 7}, {4, 3, 7}, {8, 2, 10}, {-1, 4, 3}, {3256, 4, 3260}
});
}
public CalculatorParamTest(int mOperandOne, int mOperandTwo, int mExpectedResult) {
this.mOperandOne = mOperandOne;
this.mOperandTwo = mOperandTwo;
this.mExpectedResult = mExpectedResult;
}
@Before
public void setUp() { mCalculator = new Calculator(); }
@Test
public void testAdd_TwoNumbers() {
int resultAdd = mCalculator.add(mOperandOne, mOperandTwo);
assertEquals(mExpectedResult, resultAdd, 0);
}
}
ESPRESSO
GUI Testing
OnView
OnData
gradlew connectedCheck
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> activityTestRule
= new ActivityTestRule<> (MainActivity.class);
@Test
public void helloWorldTest() {
onView(withId(R.id.hello_world))
.check(matches(withText(R.string.hello_world)));
}
}
@Test
public void helloWorldButtonTest(){
onView(withId(R.id.button))
.perform(click())
.check(matches(isEnabled()));
}
MORE TOOLS - BUT WHY??
F(ast)
I(solated)
R(epeatable)
S(elf-verifying)
T(imely) i.e. TDD not TAD
MOCKITO TEMPLATE
@Test
public void test() throws Exception {
// Arrange, prepare behavior
Helper aMock = mock(Helper.class);
when(aMock.isCalled()).thenReturn(true);
// Act
testee.doSomething(aMock);
// Assert - verify interactions
verify(aMock).isCalled();
}
when(methodIsCalled).thenReturn(aValue);
TROUBLE SHOOTING
run gradlew build from the command line
Add sdk.dir to local.properties
sdk.dir=/home/godfrey/android/sdk
TEST DRIVEN DEVELOPMENT (TDD)
Unit testing vs TDD
Why TDD
Sample app
Lessons learned
TEST DRIVEN DEVELOPMENT
Write test first
See it fail
Write simplest possible solution
to get test to pass
Refactor
Wash, Rinse, Repeat
TEST DRIVEN DEVELOPMENT
Built in regression testing
Longer life for your codebase
YAGNI feature development
Red/Green/Refactor helps
kill procrastination
TDD
You can't TDD w/o unit testing
TDD means writing the tests
before the code
TDD is more painless than
classic unit testing
UNIT TESTING
You can unit test w/o TDD
Unit tests don't mandate when
you write the tests
Unit tests are often written at
the end of a coding cycle
STEPS
Introduce Continuous Integration to build code
Configure android projects for TDD
Add minimal unit tests based on existing tests, add to CI
Show team how to create unit tests
Add testing code coverage metrics to CI, expect 5-10%
Add Espresso tests
Unit test new features or sprouts, mock existing objects
Wrap or ring fence existing code, remove unused code
Refactor wrapped code to get code coverage to 60-70%
(New refactoring in Android Studio)
CONTACT INFO
godfrey@riis.com
IOS AGENDA
Why??
Unit, UI and API testing 101
Calculator Example
No really why?? (FIRST)
ETA Detroit
XCTest
XCUI
Postman / Newman
Jenkins
WHY
Catch more mistakes
Confidently make more changes
Built in regression testing
Extend the life of your codebase
FOLLOW ALONG
git clone http://github.com/godfreynolan/CodeCraftsman
MORE TOOLS - BUT WHY??
F(ast)
I(solated)
R(epeatable)
S(elf-verifying)
T(imely) i.e. TDD not TAD
TOOLS OF THE TRADE
XCTest
Cuckoo (Mocking)
XCUI
Postman
Jenkins
CUCKOO
Add Cuckoo to the test target in Podfile
Pod install
Add Run Script to build phases
Add GeneratedMocks.swift file to tests
# Define output file; change "${PROJECT_NAME}Tests" to your test's root source folder, if it's not the default name
OUTPUT_FILE="./${PROJECT_NAME}Tests/GeneratedMocks.swift"
echo "Generated Mocks File = ${OUTPUT_FILE}"
# Define input directory; change "${PROJECT_NAME}" to your project's root source folder, if it's not the default name
INPUT_DIR="./${PROJECT_NAME}"
echo "Mocks Input Directory = ${INPUT_DIR}"
# Generate mock files; include as many input files as you'd like to create mocks for
${PODS_ROOT}/Cuckoo/run generate --testable "${PROJECT_NAME}" 
--output "${OUTPUT_FILE}" 
"${INPUT_DIR}/JSONFetcher.swift"
# ... and so forth
# After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group
XCUI
User Interface testing
Two options
▪Recorded tests
▪Roll your own
XCUI HAS 3 COMPONENTS
XCUIApplication
Launch the app
XCUIElementQuery
Find the XCUI Element to test
XCUIElement
Perform Test
CONTACT INFO
godfrey@riis.com

More Related Content

What's hot

Test code that will not slow you down
Test code that will not slow you downTest code that will not slow you down
Test code that will not slow you downKostadin Golev
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack7mind
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection7mind
 
Scala, Functional Programming and Team Productivity
Scala, Functional Programming and Team ProductivityScala, Functional Programming and Team Productivity
Scala, Functional Programming and Team Productivity7mind
 
Hitchhiker's guide to Functional Testing
Hitchhiker's guide to Functional TestingHitchhiker's guide to Functional Testing
Hitchhiker's guide to Functional TestingWiebe Elsinga
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...7mind
 
It's a Kind of Magic: Under the Covers of Spring Boot
It's a Kind of Magic: Under the Covers of Spring BootIt's a Kind of Magic: Under the Covers of Spring Boot
It's a Kind of Magic: Under the Covers of Spring BootVMware Tanzu
 
Droidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offlineDroidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offlineJavier de Pedro López
 
Test driven Infrastructure development with Ansible and Molecule
Test driven Infrastructure development with Ansible and MoleculeTest driven Infrastructure development with Ansible and Molecule
Test driven Infrastructure development with Ansible and MoleculeSerena Lorenzini
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Andrey Karpov
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacriptLei Kang
 
Java8 tgtbatu devoxxuk18
Java8 tgtbatu devoxxuk18Java8 tgtbatu devoxxuk18
Java8 tgtbatu devoxxuk18Brian Vermeer
 
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars PROIDEA
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTim Berglund
 
Test First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTest First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTim Berglund
 
軟體測試是在測試什麼?
軟體測試是在測試什麼?軟體測試是在測試什麼?
軟體測試是在測試什麼?Yao Nien Chung
 
Crushing React bugs with Jest and Enzyme
Crushing React bugs with Jest and EnzymeCrushing React bugs with Jest and Enzyme
Crushing React bugs with Jest and EnzymeAll Things Open
 
Unit tests in node.js
Unit tests in node.jsUnit tests in node.js
Unit tests in node.jsRotem Tamir
 

What's hot (20)

Test code that will not slow you down
Test code that will not slow you downTest code that will not slow you down
Test code that will not slow you down
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
 
Unit Testing in iOS
Unit Testing in iOSUnit Testing in iOS
Unit Testing in iOS
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
 
Scala, Functional Programming and Team Productivity
Scala, Functional Programming and Team ProductivityScala, Functional Programming and Team Productivity
Scala, Functional Programming and Team Productivity
 
Hitchhiker's guide to Functional Testing
Hitchhiker's guide to Functional TestingHitchhiker's guide to Functional Testing
Hitchhiker's guide to Functional Testing
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
 
It's a Kind of Magic: Under the Covers of Spring Boot
It's a Kind of Magic: Under the Covers of Spring BootIt's a Kind of Magic: Under the Covers of Spring Boot
It's a Kind of Magic: Under the Covers of Spring Boot
 
Droidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offlineDroidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offline
 
Test driven Infrastructure development with Ansible and Molecule
Test driven Infrastructure development with Ansible and MoleculeTest driven Infrastructure development with Ansible and Molecule
Test driven Infrastructure development with Ansible and Molecule
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacript
 
Java8 tgtbatu devoxxuk18
Java8 tgtbatu devoxxuk18Java8 tgtbatu devoxxuk18
Java8 tgtbatu devoxxuk18
 
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in Grails
 
Test First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTest First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in Grails
 
Qunit Java script Un
Qunit Java script UnQunit Java script Un
Qunit Java script Un
 
軟體測試是在測試什麼?
軟體測試是在測試什麼?軟體測試是在測試什麼?
軟體測試是在測試什麼?
 
Crushing React bugs with Jest and Enzyme
Crushing React bugs with Jest and EnzymeCrushing React bugs with Jest and Enzyme
Crushing React bugs with Jest and Enzyme
 
Unit tests in node.js
Unit tests in node.jsUnit tests in node.js
Unit tests in node.js
 

Similar to Mobile Agile Testing Guide for Android and iOS

1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example usingIevgenii Katsan
 
Google test training
Google test trainingGoogle test training
Google test trainingThierry Gayet
 
7 stages of unit testing
7 stages of unit testing7 stages of unit testing
7 stages of unit testingJorge Ortiz
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And DrupalPeter Arato
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Comunidade NetPonto
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockRobot Media
 
The real beginner's guide to android testing
The real beginner's guide to android testingThe real beginner's guide to android testing
The real beginner's guide to android testingEric (Trung Dung) Nguyen
 
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonUnit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonbeITconference
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developersAnton Udovychenko
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
Testing with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifeTesting with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifePeter Gfader
 
Mutation testing Bucharest Tech Week
Mutation testing Bucharest Tech WeekMutation testing Bucharest Tech Week
Mutation testing Bucharest Tech WeekPaco van Beckhoven
 
Android testing
Android testingAndroid testing
Android testingSean Tsai
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 

Similar to Mobile Agile Testing Guide for Android and iOS (20)

1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example using
 
Google test training
Google test trainingGoogle test training
Google test training
 
7 stages of unit testing
7 stages of unit testing7 stages of unit testing
7 stages of unit testing
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 
Getting Started With Testing
Getting Started With TestingGetting Started With Testing
Getting Started With Testing
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
The real beginner's guide to android testing
The real beginner's guide to android testingThe real beginner's guide to android testing
The real beginner's guide to android testing
 
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonUnit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Design for Testability
Design for TestabilityDesign for Testability
Design for Testability
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Testing with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifeTesting with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs Life
 
Mutation testing Bucharest Tech Week
Mutation testing Bucharest Tech WeekMutation testing Bucharest Tech Week
Mutation testing Bucharest Tech Week
 
Android testing
Android testingAndroid testing
Android testing
 
Testing
TestingTesting
Testing
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 

More from Godfrey Nolan

Counting Cars with Drones
Counting Cars with DronesCounting Cars with Drones
Counting Cars with DronesGodfrey Nolan
 
Customising QGroundControl
Customising QGroundControlCustomising QGroundControl
Customising QGroundControlGodfrey Nolan
 
Parrot Tutorials in Kotlin
Parrot Tutorials in KotlinParrot Tutorials in Kotlin
Parrot Tutorials in KotlinGodfrey Nolan
 
DJI Mobile SDK Tutorials in kotlin
DJI Mobile SDK Tutorials in kotlinDJI Mobile SDK Tutorials in kotlin
DJI Mobile SDK Tutorials in kotlinGodfrey Nolan
 
Getting started with tensor flow datasets
Getting started with tensor flow datasets Getting started with tensor flow datasets
Getting started with tensor flow datasets Godfrey Nolan
 
Using ML to make your UI tests more robust
Using ML to make your UI tests more robustUsing ML to make your UI tests more robust
Using ML to make your UI tests more robustGodfrey Nolan
 
Counting sheep with Drones and AI
Counting sheep with Drones and AICounting sheep with Drones and AI
Counting sheep with Drones and AIGodfrey Nolan
 
Writing Secure Mobile Apps for Drones
Writing Secure Mobile Apps for DronesWriting Secure Mobile Apps for Drones
Writing Secure Mobile Apps for DronesGodfrey Nolan
 
The Day We Infected Ourselves with Ransomware
The Day We Infected Ourselves with RansomwareThe Day We Infected Ourselves with Ransomware
The Day We Infected Ourselves with RansomwareGodfrey Nolan
 
From Maps to Apps the Future of Drone Technology
From Maps to Apps the Future of Drone TechnologyFrom Maps to Apps the Future of Drone Technology
From Maps to Apps the Future of Drone TechnologyGodfrey Nolan
 
Tableau 10 and quickbooks
Tableau 10 and quickbooksTableau 10 and quickbooks
Tableau 10 and quickbooksGodfrey Nolan
 
Network graphs in tableau
Network graphs in tableauNetwork graphs in tableau
Network graphs in tableauGodfrey Nolan
 

More from Godfrey Nolan (20)

Counting Cars with Drones
Counting Cars with DronesCounting Cars with Drones
Counting Cars with Drones
 
Customising QGroundControl
Customising QGroundControlCustomising QGroundControl
Customising QGroundControl
 
DJI Payload SDK
DJI Payload SDKDJI Payload SDK
DJI Payload SDK
 
Parrot Tutorials in Kotlin
Parrot Tutorials in KotlinParrot Tutorials in Kotlin
Parrot Tutorials in Kotlin
 
DJI Mobile SDK Tutorials in kotlin
DJI Mobile SDK Tutorials in kotlinDJI Mobile SDK Tutorials in kotlin
DJI Mobile SDK Tutorials in kotlin
 
Drone sdk showdown
Drone sdk showdownDrone sdk showdown
Drone sdk showdown
 
AI/ML in drones
AI/ML in dronesAI/ML in drones
AI/ML in drones
 
Getting started with tensor flow datasets
Getting started with tensor flow datasets Getting started with tensor flow datasets
Getting started with tensor flow datasets
 
Using ML to make your UI tests more robust
Using ML to make your UI tests more robustUsing ML to make your UI tests more robust
Using ML to make your UI tests more robust
 
Java best practices
Java best practicesJava best practices
Java best practices
 
Counting sheep with Drones and AI
Counting sheep with Drones and AICounting sheep with Drones and AI
Counting sheep with Drones and AI
 
Writing Secure Mobile Apps for Drones
Writing Secure Mobile Apps for DronesWriting Secure Mobile Apps for Drones
Writing Secure Mobile Apps for Drones
 
Android Device Labs
Android Device LabsAndroid Device Labs
Android Device Labs
 
The Day We Infected Ourselves with Ransomware
The Day We Infected Ourselves with RansomwareThe Day We Infected Ourselves with Ransomware
The Day We Infected Ourselves with Ransomware
 
Agile Swift
Agile SwiftAgile Swift
Agile Swift
 
Android Refactoring
Android RefactoringAndroid Refactoring
Android Refactoring
 
From Maps to Apps the Future of Drone Technology
From Maps to Apps the Future of Drone TechnologyFrom Maps to Apps the Future of Drone Technology
From Maps to Apps the Future of Drone Technology
 
Tableau 10 and quickbooks
Tableau 10 and quickbooksTableau 10 and quickbooks
Tableau 10 and quickbooks
 
Network graphs in tableau
Network graphs in tableauNetwork graphs in tableau
Network graphs in tableau
 
Bulletproof
BulletproofBulletproof
Bulletproof
 

Recently uploaded

定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMartaLoveguard
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Intellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxIntellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxBipin Adhikari
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 

Recently uploaded (20)

定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptx
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Intellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxIntellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptx
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 

Mobile Agile Testing Guide for Android and iOS

  • 3. ANDROID AGENDA Why?? Unit, UI and API testing 101 Calculator Example More Tools - FIRST ETA Detroit jUnit Testing Espresso Postman / Newman Jenkins
  • 4.
  • 5. IOS AGENDA Why?? Unit, UI and API testing 101 Calculator Example No really why?? (FIRST) ETA Detroit XCTest XCUI Postman / Newman Jenkins
  • 6. FOLLOW ALONG git clone http://github.com/godfreynolan/CodeCraftsman
  • 7. WHY Catch more mistakes Confidently make more changes Built in regression testing Extend the life of your codebase
  • 8.
  • 9. UNIT TESTING INTRO public double add(double firstOperand, double secondOperand) { return firstOperand + secondOperand; } @Test public void calculator_CorrectAdd_ReturnsTrue() { assertEquals(7, add(3,4); } @Test public void calculator_CorrectAdd_ReturnsTrue() { assertEquals("Addition is broken", 7, add(3,4); }
  • 10. dependencies { // Unit testing dependencies. testCompile 'junit:junit:4.12' }
  • 11.
  • 12. UNIT TESTING 101 Command line Setup and Teardown Assertions Parameters Code Coverage
  • 13. C:UsersgodfreyAndroidStudioProjectsBasicSample>gradlew test --continue Downloading https://services.gradle.org/distributions/gradle-2.2.1-all.zip ................................................................................ .................................................. Unzipping C:Usersgodfrey.gradlewrapperdistsgradle-2.2.1-all6dibv5rcnnqlfbq9klf8imrndn Download https://jcenter.bintray.com/com/google/guava/guava/17.0/guava-17.0.jar Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/24.2.3/lint-api-24.2.3.j Download https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.jar Download https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombo :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:prepareDebugDependencies :app:compileDebugAidl :app:compileDebugRenderscript . . . :app:compileReleaseUnitTestSources :app:assembleReleaseUnitTest :app:testRelease :app:test BUILD SUCCESSFUL Total time: 3 mins 57.013 secs
  • 14. public class CalculatorTest { private Calculator mCalculator; @Before public void setUp() { mCalculator = new Calculator(); } @Test public void calculator_CorrectAdd_ReturnsTrue() { double resultAdd = mCalculator.add(3, 4); assertEquals(7, resultAdd,0); } @After public void tearDown() { mCalculator = null; } }
  • 16. @RunWith(Parameterized.class) public class CalculatorParamTest { private int mOperandOne, mOperandTwo, mExpectedResult; private Calculator mCalculator; @Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { {3, 4, 7}, {4, 3, 7}, {8, 2, 10}, {-1, 4, 3}, {3256, 4, 3260} }); } public CalculatorParamTest(int mOperandOne, int mOperandTwo, int mExpectedResult) { this.mOperandOne = mOperandOne; this.mOperandTwo = mOperandTwo; this.mExpectedResult = mExpectedResult; } @Before public void setUp() { mCalculator = new Calculator(); } @Test public void testAdd_TwoNumbers() { int resultAdd = mCalculator.add(mOperandOne, mOperandTwo); assertEquals(mExpectedResult, resultAdd, 0); } }
  • 17.
  • 18.
  • 19.
  • 21.
  • 22.
  • 23.
  • 24. @RunWith(AndroidJUnit4.class) @LargeTest public class MainActivityTest { @Rule public ActivityTestRule<MainActivity> activityTestRule = new ActivityTestRule<> (MainActivity.class); @Test public void helloWorldTest() { onView(withId(R.id.hello_world)) .check(matches(withText(R.string.hello_world))); } } @Test public void helloWorldButtonTest(){ onView(withId(R.id.button)) .perform(click()) .check(matches(isEnabled())); }
  • 25. MORE TOOLS - BUT WHY?? F(ast) I(solated) R(epeatable) S(elf-verifying) T(imely) i.e. TDD not TAD
  • 26.
  • 27. MOCKITO TEMPLATE @Test public void test() throws Exception { // Arrange, prepare behavior Helper aMock = mock(Helper.class); when(aMock.isCalled()).thenReturn(true); // Act testee.doSomething(aMock); // Assert - verify interactions verify(aMock).isCalled(); } when(methodIsCalled).thenReturn(aValue);
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45. TROUBLE SHOOTING run gradlew build from the command line Add sdk.dir to local.properties sdk.dir=/home/godfrey/android/sdk
  • 46.
  • 47. TEST DRIVEN DEVELOPMENT (TDD) Unit testing vs TDD Why TDD Sample app Lessons learned
  • 48. TEST DRIVEN DEVELOPMENT Write test first See it fail Write simplest possible solution to get test to pass Refactor Wash, Rinse, Repeat
  • 49. TEST DRIVEN DEVELOPMENT Built in regression testing Longer life for your codebase YAGNI feature development Red/Green/Refactor helps kill procrastination
  • 50. TDD You can't TDD w/o unit testing TDD means writing the tests before the code TDD is more painless than classic unit testing UNIT TESTING You can unit test w/o TDD Unit tests don't mandate when you write the tests Unit tests are often written at the end of a coding cycle
  • 51. STEPS Introduce Continuous Integration to build code Configure android projects for TDD Add minimal unit tests based on existing tests, add to CI Show team how to create unit tests Add testing code coverage metrics to CI, expect 5-10% Add Espresso tests Unit test new features or sprouts, mock existing objects Wrap or ring fence existing code, remove unused code Refactor wrapped code to get code coverage to 60-70% (New refactoring in Android Studio)
  • 52.
  • 54. IOS AGENDA Why?? Unit, UI and API testing 101 Calculator Example No really why?? (FIRST) ETA Detroit XCTest XCUI Postman / Newman Jenkins
  • 55.
  • 56.
  • 57.
  • 58. WHY Catch more mistakes Confidently make more changes Built in regression testing Extend the life of your codebase
  • 59.
  • 60. FOLLOW ALONG git clone http://github.com/godfreynolan/CodeCraftsman
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74. MORE TOOLS - BUT WHY?? F(ast) I(solated) R(epeatable) S(elf-verifying) T(imely) i.e. TDD not TAD
  • 75. TOOLS OF THE TRADE XCTest Cuckoo (Mocking) XCUI Postman Jenkins
  • 76.
  • 77.
  • 78.
  • 79. CUCKOO Add Cuckoo to the test target in Podfile Pod install Add Run Script to build phases Add GeneratedMocks.swift file to tests
  • 80.
  • 81. # Define output file; change "${PROJECT_NAME}Tests" to your test's root source folder, if it's not the default name OUTPUT_FILE="./${PROJECT_NAME}Tests/GeneratedMocks.swift" echo "Generated Mocks File = ${OUTPUT_FILE}" # Define input directory; change "${PROJECT_NAME}" to your project's root source folder, if it's not the default name INPUT_DIR="./${PROJECT_NAME}" echo "Mocks Input Directory = ${INPUT_DIR}" # Generate mock files; include as many input files as you'd like to create mocks for ${PODS_ROOT}/Cuckoo/run generate --testable "${PROJECT_NAME}" --output "${OUTPUT_FILE}" "${INPUT_DIR}/JSONFetcher.swift" # ... and so forth # After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group
  • 82.
  • 83.
  • 84.
  • 85.
  • 86. XCUI User Interface testing Two options ▪Recorded tests ▪Roll your own
  • 87.
  • 88. XCUI HAS 3 COMPONENTS XCUIApplication Launch the app XCUIElementQuery Find the XCUI Element to test XCUIElement Perform Test
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.