SlideShare una empresa de Scribd logo
1 de 70
Descargar para leer sin conexión
Oh you test?
cool test bro
Paul Blundell
@blundell_apps
blog.blundellapps.com github.com/blundell
AutoTrader
- Define different types of testing
- Clarify testing & naming
- Benefits of each type of testing
- Codez available to help you
- Some architecture hints & tips
Abstract
Test Types
- Unit Tests
- Integration Tests
- Functional Tests
- Acceptance Tests
- Mutation Tests
- Vendor Tests
- Fuzz Tests
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Test a single block of code / function
- Test independently from collaborators
- Only test against interface definitions
- New behaviour : new unit test
Unit Tests - What
@Test
public void testGetLastPathSegmentReturnsFilename() {
SecureUrl secureUrl = new SecureUrl(
"http://test.com/some/random/url/filename.mp4");
String lastPathSegment = secureUrl.getLastPathSegment();
assertThat(lastPathSegment).isEqualTo("filename.mp4");
}
Unit Tests - Example
- Daily development work
- Allow for continuous refactoring
- Test Driven Development
- Documentation for legacy developers
Unit Tests - When
Unit Tests - Where
- All building blocks
- All levels of an application architecture
- Help pinpoint a place of failure
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Highlight UI issues
- Guarantee combined system integrity
- Prove integration of components
Unit Tests - Won’t
- Interaction between two or more classes
- Use real objects
- Can use threads
- Can access database
Integration Tests - What
@Test(expected = IllegalStateException.class)
public void testFindFragmentWithUnknownTagResourceIdThrowsError() {
Activity activity = Robolectric.buildActivity(Activity.class).get();
FragmentManager fM = activity.getFragmentManager();
Resources resources = activity.getResources();
TaskFragmentFinder finder = new TaskFragmentFinder(resources);
finder.findTaskFragment(fM, UNKNOWN_TASK_ID);
}
Integration Tests - Example
- Ensure parity of collaboration between objects
- Testing expected changes - db schema
- Testing environment integration
Integration Tests - When
- All building blocks
- Interactions between layers
- Help pinpoint integration issues
Integration Tests - Where
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Highlight UI issues
- Show specific code block of failure
- Give instant feedback
- Hard to diagnose some failures
- Full system confidence
Integration Tests - Won’t
- Whole system, nearly end to end
- Don’t care about intermediary steps
- Slower to run
- Mostly controller driven
Functional Tests - What
public void testShowsFilmInformationAfterApiCallFinished() {
String expectedTitle = "Swimming Pool";
startFilmActivity();
onData(is(instanceOf(Film.class)))
.atPosition(FIRST)
.onChildView(withId(R.id.film_text_view_title))
.check(matches(allOf(isDisplayed(),
withText(equalToIgnoringCase(expectedTitle)))));
}
Functional Tests - Example
- Evaluate expectation of sum of the parts
- Confirming feature completion
- TDD Keep you focused
- Confidence in features of system
Functional Tests - When
- Span whole architecture
- Touching live systems
- Above integrated components
Functional Tests - Where
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Show specific broken units of code
- Lack of knowledge of the details
- Give quick feedback for specific problems
Functional Tests - Won’t
- Black box tests
- From user perspective
- Specialised form of functional tests
- Model the final complete system
Acceptance Tests - What
public void testRotationInBrowseScreenMaintainsActionBar() {
swipeToBrowseScreen();
Activity activity = rotate(this);
assertActionBarOpen(activity);
}
private void assertActionBarOpen(Activity activity) {
assertTrue("Expected ActionBar open but was closed.",
activity.getActionBar().isShowing());
}
Acceptance Tests - Example
- User interface is integrated
- TDD feedback loop
- Capturing differences across devices
- Screenshots for greater feedback
Acceptance Tests - When
- Span whole architecture
- Touching live systems
- Above integrated components
Acceptance Tests - Where
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Run very fast
- No feedback upon cause (just symptoms)
- Help day-to-day incremental improvements
Acceptance Tests - Won’t
- Mutate the state of your code
- Insert faults in your software
- Unit tests are ran
- Tests fail “mutant is killed” thumbs up
- Tests pass “mutant survived” thumbs down
Mutation Tests - What
Oh so you test? - A guide to testing on Android from Unit to Mutation
Mutation Tests - Example
if (a == b) {
// do something
}
will be mutated to
if (a != b) {
// do something
}
Different
Mutators:
if (a == b) {
// do something
}
will be mutated to
if (true) {
// do something
}
public int method(int i) {
i++;
return i;
}
will be mutated to
public int method(int i) {
i--;
return i;
}
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Find holes in your test suite
- Depends on % code coverage
- Confidence in your unit tests
- Complexity of your problem is high
Mutation Tests - When
- Outside of your code
- Around your test suite
- Not written yourself but configured
- Configuration is key
Mutation Tests - Where
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Give any confidence in working software
- Show collaboration between objects
- Prove if the application actually works
- Help at all without unit tests
Mutation Tests - Won’t
- can be unit, integration, functional
- learn how 3rd
party libraries work
- confirming understanding
- safety net for outside changes
Vendor Tests - What
@Test
public void setAndGetActiveSessionAreTrustworthy() {
Session.setActiveSession(mockFacebookSession);
FacebookSession session = Session.getActiveSession();
assertThat(mockFacebookSession).isEqualTo(session);
}
Vendor Tests - Example
- Incorporating 3rd party library
- Not beneficial to add retrospectively
- Replacing libraries with confidence
- Wanting to ‘in house’ a library feature
Vendor Tests - When
- Around your 3rd party libraries
- One off test
- Suite inside unit tests
Vendor Tests - Where
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Confirm your domain code
- Replace unit, integration or acceptance tests
- Adds overhead to development
Vendor Tests - Won’t
- Feeding your software random data
- Wait to see what breaks
- It is not logical
- Android = Application Exerciser Monkey
- Combinatory with other tools
Fuzz Tests - What
adb shell monkey -p com.your.package.name -v 50000
Fuzz Tests - Example
// Allowing start of Intent { act=mubi.intent.action.ON_BOARD cmp=com.mubi/.onboard.OnboardActivity } in package com.
mubi
:Sending Touch (ACTION_DOWN): 0:(1091.0,659.0)
:Sending Touch (ACTION_UP): 0:(1085.1356,667.17145)
:Sending Touch (ACTION_DOWN): 0:(467.0,404.0)
:Sending Touch (ACTION_UP): 0:(472.5769,398.45746)
// CRASH: com.mubi (pid 754)
// Short Msg: java.lang.IllegalStateException
// Long Msg: java.lang.IllegalStateException: Fragment WatchFragment{413d0d98} is not currently in the FragmentManager
// Build Label: google/nakasi/grouper:4.1.1/JRO03H/405518:user/release-keys
// Build Changelist: 405518
// Build Time: 1364293068000
// java.lang.IllegalStateException: Fragment WatchFragment{413d0d98} is not currently in the FragmentManager
// at android.app.FragmentManagerImpl.saveFragmentInstanceState(FragmentManager.java:586)
// at android.support.v13.app.FragmentStatePagerAdapter.destroyItem(FragmentStatePagerAdapter.java:140)
// at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:413)
// at com.mubi.onboard.OnboardActivity.updateViewPager(OnboardActivity.java:139)
// at com.mubi.onboard.OnboardActivity.onRetrieved(OnboardActivity.java:132)
// at com.mubi.onboard.OnboardTaskFragment$3.run(OnboardTaskFragment.java:77)
// at android.os.Handler.handleCallback(Handler.java:725)
// at android.os.Handler.dispatchMessage(Handler.java:92)
// at android.os.Looper.loop(Looper.java:137)
// at android.app.ActivityThread.main(ActivityThread.java:5195)
// at java.lang.reflect.Method.invokeNative(Native Method)
// at java.lang.reflect.Method.invoke(Method.java:511)
// at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
// at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
// at com.android.internal.os.ZygoteInit.main(Native Method)
// at dalvik.system.NativeStart.main(Native Method)
//
** Monkey aborted due to error.
Events injected: 4191
- From the beginning
- Thin slice (UI)
- Continuous integration, faster feedback
- Identifying differences across Android versions
- Highlight refactoring effort
Fuzz Tests - When
- Black box testing
- On top of your application (Android)
- Custom fuzz testing - input level
- Continuous integration
Fuzz Tests - Where
Oh so you test? - A guide to testing on Android from Unit to Mutation
- Prove application is running correctly
- Only reports crashes
- Highlights quality rather than bugs
- Not a replacement for unit, integration etc
Fuzz Tests - Won’t
Helpers / Libraries
- Brief overview
- What test types it benefits
- Any positives
- Any negatives
Mockito
//mock creation
List mockedList = mock(List.class);
//using mock object - doesn’t throw exceptions
mockedList.add(“one”);
//selective & explicit verification
verify(mockList).add(“one”);
Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with clean
& simple API. Mockito doesn't give you a hangover because the tests are very readable and they
produce clean verification errors.
- Unit Tests : mocking dependencies
- Integration Tests : questionable use
Fest
FEST is a collection of libraries, whose mission is to simplify software testing.
No more confusion about the order of the "expected" and "actual" values. Our assertions are very
readable as well: they read very close to plain English, making it easier for non-technical people
to read test code.
Regular JUnit:
assertEquals(View.GONE, view.getVisibility());
Regular FEST:
assertThat(view.getVisibility()).isEqualTo(View.GONE);
FEST Android:
assertThat(view).isGone(); - Unit Tests
- Integration Tests
- Functional Tests
- Acceptance Tests : anywhere you do assertions
improving readability
“Robolectric is a unit test framework that de-fangs the Android SDK jar so you can test-drive the
development of your Android app. Tests run inside the JVM on your workstation in seconds. “
Robolectric
@RunWith(RobolectricTestRunner.class)
public class ViewingQueryTaskTest {
@Test
public void testAlwaysClosesCursor() {
viewingQueryTask.run();
verify(mockCursor).close();
}
}
- Unit tests : for day to day activity including TDD
- Integration tests : to handle Android
- Positive : speed vs on device tests
- Negative : the rabbit hole
“Robotium is an Android test automation framework. Robotium makes it easy to write powerful
and robust automatic black-box UI tests. With the support of Robotium, test case developers can
write functional and user acceptance test scenarios, spanning multiple Android activities.“
Robotium
- Functional tests : check when you click a button the
shared preferences are updated
- Acceptance tests : ensure features have been
completed and take screenshots for feedback
public class EditorTest extends ActivityInstrumentationTestCase2<EditorActivity> {
private Solo solo;
public void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
public void testFileExtensionIsInMenu() {
solo.sendKey(Solo.MENU);
solo.clickOnText("More");
solo.clickOnText("Preferences");
solo.clickOnText("Edit File Extensions");
Assert.assertTrue(solo.searchText("rtf"));
}
}
Use Espresso to write concise, beautiful, and reliable Android UI tests
Espresso tests state expectations, interactions, and assertions clearly without the distraction of boilerplate
content, custom infrastructure, or messy implementation details getting in the way.
Espresso
public void testSayHello() {
onView(withId(R.id.name_field).perform(typeText("Dave"));
onView(withId(R.id.greet_button)).perform(click());
onView(withText("Hello Dave!")).check(matches(isDisplayed()));
}
- Functional tests : check when you click a button the shared
preferences are updated
- Acceptance tests : ensure features have been completed, doesn’t
support screenshots as an API but you can still do it
http://tiny.cc/disableAnim
http://tiny.cc/espressoScreenshot
The Monkey is a program that runs on your emulator or device and generates pseudo-random
streams of user events such as clicks, touches, or gestures, as well as a number of system-level
events. You can use the Monkey to stress-test applications that you are developing, in a random
yet repeatable manner.
UI Exerciser Monkey
adb shell monkey -p com.your.package.name -v
50000
- Fuzz tests : as already discussed allows you to test input events
Don’t get the Application Exerciser Monkey & the Monkey Runner mixed
up.
App Ex Monkey – Fuzz Testing
Monkey Runner – Android device control using Python scripts
The uiautomator testing framework lets you test your user interface (UI) efficiently by
creating automated functional UI testcases that can be run against your app on one or more
devices.
UI Automator
extend UIAutomatorTestCase
UIObject & UISelector
Min SDK 16 Jelly Bean
adb shell uiautomator runtest MyTests.jar -c com.example.MyApp
Tests are in the jar, and the package is the package of the app under test.
- Acceptance tests : acts just like a user.
Architecture Empower / Encumber
- Allows for separation of concerns
- Java only module
- Directed testing
- Encapsulating change
- Reuse
Modules / Modularity Empowers
- Readable & flexible CI builds
- Flavors, build types
- Swapping out whole components
- Greater range of testing flexibility
Gradle Empowers
- Test reliability
- Test speed
- Data integrity
Mock Services Empower
- Hexagonal architecture
- Insulates system from outside dependencies
- Empowers testing
- Disconnect from platform requirements
Ports & Adapters Empower
S.O.L.I.D Empowers
- Quality of your code reflects quality of your
tests
- Object Oriented programming lends itself to
quality testing
- TDD
- Static methods are evil
Low Code Quality Encumbers
- Framework lock in
- Google Play services
- Android code examples
- Activity life cycle
Android (frameworks) Encumber
- Believe in testing
- Believe in clean code
- Software craftsmanship
- TDD
- Be energetic
- Enjoy it
YOU Empower || Encumber
Monkey Runner
Spoon
Jmock
Hexagonal Architecture
Contract Tests
Others
Groovy Tests
Static analysis tools
Charles
cURL
Postman
Google sizes (small medium large)
We are hiring developers
Online Blogs
Martin Fowler http://martinfowler.com/tags/testing.html
JB Rainsberger http://blog.thecodewhisperer.com/
Kevin Rutherford http://silkandspinach.net/
Robert Martin https://sites.google.com/site/unclebobconsultingllc/blogs-by-robert-martin
References
More Info
Android Fuzz Tests http://developer.android.com/tools/help/monkey.html
Hardcore Fuzz Tests http://www.ibm.com/developerworks/library/j-fuzztest/index.html
Vendor Tests https://www.youtube.com/watch?v=47nuBTRB51c#t=23m34s
Mutation Tests http://pitest.org/
Google Testing Opinion http://googletesting.blogspot.co.uk/2010/12/test-sizes.html
Mockito https://code.google.com/p/mockito/
Mocking Frameworks http://blogs.telerik.com/skimedic/posts/13-07-23/top-5-reasons-to-use-a-mocking-framework
Android Fest https://github.com/square/fest-android
Robolectric http://robolectric.org/
Robotium https://code.google.com/p/robotium/
Espresso https://code.google.com/p/android-test-kit/wiki/Espresso
UI Automator http://developer.android.com/tools/help/uiautomator/index.html
SOLID Principles http://www.its-on-the-internet-so-it-must-be-true.com/2012/06/solid-principles.html
Paul Blundell
Questions?
@blundell_apps

Más contenido relacionado

La actualidad más candente

Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockitoshaunthomas999
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Deepak Singhvi
 
Software Testing
Software TestingSoftware Testing
Software TestingAdroitLogic
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testingalessiopace
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit TestingMike Lively
 
Clean Unit Test Patterns
Clean Unit Test PatternsClean Unit Test Patterns
Clean Unit Test PatternsFrank Appel
 
.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010kgayda
 
Testing for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test AutomationTesting for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test AutomationTrent Peterson
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated TestingLee Englestone
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Hong Le Van
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android ApplicationsRody Middelkoop
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummiesHarry Potter
 
Unit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveUnit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveAlvaro Videla
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management toolRenato Primavera
 

La actualidad más candente (20)

Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test Automation
 
Test ng
Test ngTest ng
Test ng
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Unit test
Unit testUnit test
Unit test
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
Codeception
CodeceptionCodeception
Codeception
 
Clean Unit Test Patterns
Clean Unit Test PatternsClean Unit Test Patterns
Clean Unit Test Patterns
 
.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010
 
Testing for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test AutomationTesting for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test Automation
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummies
 
Unit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveUnit Test + Functional Programming = Love
Unit Test + Functional Programming = Love
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
 

Destacado

Judge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughJudge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughPaul Blundell
 
Justice ,justice shall you pursue
Justice ,justice shall you pursueJustice ,justice shall you pursue
Justice ,justice shall you pursueYonatanKay1
 
Kesetimbangan kimia
Kesetimbangan kimiaKesetimbangan kimia
Kesetimbangan kimiawidhiyani
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimiawidhiyani
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimiawidhiyani
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimiawidhiyani
 
Phoenix presentation
Phoenix presentationPhoenix presentation
Phoenix presentationYonatanKay1
 
Roditelskoe sobranie 11klassy
Roditelskoe sobranie 11klassyRoditelskoe sobranie 11klassy
Roditelskoe sobranie 11klassylili4ka54
 
Entrepreneurship from a regional market perspective
Entrepreneurship from a regional market perspectiveEntrepreneurship from a regional market perspective
Entrepreneurship from a regional market perspectiveRajaranjan Senapati
 
Panduan microsoft word_20071
Panduan microsoft word_20071Panduan microsoft word_20071
Panduan microsoft word_20071Amri Abdillah
 
Survival of the Continuist
Survival of the ContinuistSurvival of the Continuist
Survival of the ContinuistPaul Blundell
 
สอบปฏิบัติ
สอบปฏิบัติสอบปฏิบัติ
สอบปฏิบัติSupanit
 
школа – дом, в котором наше детство
школа – дом, в котором наше детствошкола – дом, в котором наше детство
школа – дом, в котором наше детствоlili4ka54
 
Fundamentals of relationship marketing a relationship-perspective_chapter1 se...
Fundamentals of relationship marketing a relationship-perspective_chapter1 se...Fundamentals of relationship marketing a relationship-perspective_chapter1 se...
Fundamentals of relationship marketing a relationship-perspective_chapter1 se...Divya Kansha
 
A paixão de nosso senhor jesus cristo v. ii
A paixão de nosso senhor jesus cristo v. ii   A paixão de nosso senhor jesus cristo v. ii
A paixão de nosso senhor jesus cristo v. ii Jose Agnaldo Gasques
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kataPaul Blundell
 
An easy way to automate complex UI
An easy way to automate complex UIAn easy way to automate complex UI
An easy way to automate complex UIIvan Pashko
 

Destacado (20)

Espresso Barista
Espresso BaristaEspresso Barista
Espresso Barista
 
Judge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughJudge my gym - GymBabes Walkthrough
Judge my gym - GymBabes Walkthrough
 
Justice ,justice shall you pursue
Justice ,justice shall you pursueJustice ,justice shall you pursue
Justice ,justice shall you pursue
 
Kesetimbangan kimia
Kesetimbangan kimiaKesetimbangan kimia
Kesetimbangan kimia
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimia
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimia
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimia
 
Y U NO CRAFTSMAN
Y U NO CRAFTSMANY U NO CRAFTSMAN
Y U NO CRAFTSMAN
 
Phoenix presentation
Phoenix presentationPhoenix presentation
Phoenix presentation
 
Roditelskoe sobranie 11klassy
Roditelskoe sobranie 11klassyRoditelskoe sobranie 11klassy
Roditelskoe sobranie 11klassy
 
Open house2
Open house2Open house2
Open house2
 
Entrepreneurship from a regional market perspective
Entrepreneurship from a regional market perspectiveEntrepreneurship from a regional market perspective
Entrepreneurship from a regional market perspective
 
Panduan microsoft word_20071
Panduan microsoft word_20071Panduan microsoft word_20071
Panduan microsoft word_20071
 
Survival of the Continuist
Survival of the ContinuistSurvival of the Continuist
Survival of the Continuist
 
สอบปฏิบัติ
สอบปฏิบัติสอบปฏิบัติ
สอบปฏิบัติ
 
школа – дом, в котором наше детство
школа – дом, в котором наше детствошкола – дом, в котором наше детство
школа – дом, в котором наше детство
 
Fundamentals of relationship marketing a relationship-perspective_chapter1 se...
Fundamentals of relationship marketing a relationship-perspective_chapter1 se...Fundamentals of relationship marketing a relationship-perspective_chapter1 se...
Fundamentals of relationship marketing a relationship-perspective_chapter1 se...
 
A paixão de nosso senhor jesus cristo v. ii
A paixão de nosso senhor jesus cristo v. ii   A paixão de nosso senhor jesus cristo v. ii
A paixão de nosso senhor jesus cristo v. ii
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kata
 
An easy way to automate complex UI
An easy way to automate complex UIAn easy way to automate complex UI
An easy way to automate complex UI
 

Similar a Oh so you test? - A guide to testing on Android from Unit to Mutation

An introduction to unit testing
An introduction to unit testingAn introduction to unit testing
An introduction to unit testingAdam Stephensen
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
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 php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in JavaMichael Fons
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And DrupalPeter Arato
 
Unit testing using Munit Part 1
Unit testing using Munit Part 1Unit testing using Munit Part 1
Unit testing using Munit Part 1Anand kalla
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
Into The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsInto The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsOrtus Solutions, Corp
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4Billie Berzinskas
 

Similar a Oh so you test? - A guide to testing on Android from Unit to Mutation (20)

An introduction to unit testing
An introduction to unit testingAn introduction to unit testing
An introduction to unit testing
 
Presentation
PresentationPresentation
Presentation
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
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 php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 
Unit testing using Munit Part 1
Unit testing using Munit Part 1Unit testing using Munit Part 1
Unit testing using Munit Part 1
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
Skillwise Unit Testing
Skillwise Unit TestingSkillwise Unit Testing
Skillwise Unit Testing
 
Into The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsInto The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applications
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
 
Modern Python Testing
Modern Python TestingModern Python Testing
Modern Python Testing
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 

Más de Paul Blundell

In 10 mins a software crafting journey
In 10 mins a software crafting journeyIn 10 mins a software crafting journey
In 10 mins a software crafting journeyPaul Blundell
 
The Novoda Craft University
The Novoda Craft UniversityThe Novoda Craft University
The Novoda Craft UniversityPaul Blundell
 
Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid FoundationsPaul Blundell
 
Http Caching for the Android Aficionado
Http Caching for the Android AficionadoHttp Caching for the Android Aficionado
Http Caching for the Android AficionadoPaul Blundell
 
My perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsMy perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsPaul Blundell
 
Java Patterns - Strategy
Java Patterns - StrategyJava Patterns - Strategy
Java Patterns - StrategyPaul Blundell
 
Google I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsGoogle I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsPaul Blundell
 
Android Jam - Services & Notifications - Udacity Lesson 6
Android Jam - Services & Notifications - Udacity Lesson 6 Android Jam - Services & Notifications - Udacity Lesson 6
Android Jam - Services & Notifications - Udacity Lesson 6 Paul Blundell
 
Android Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cAndroid Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cPaul Blundell
 
Android Jam - ContentProviders - Udacity Lesson 4b
Android Jam - ContentProviders - Udacity Lesson 4bAndroid Jam - ContentProviders - Udacity Lesson 4b
Android Jam - ContentProviders - Udacity Lesson 4bPaul Blundell
 
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4aAndroid Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4aPaul Blundell
 
Jenkins project based authorization
Jenkins   project based authorizationJenkins   project based authorization
Jenkins project based authorizationPaul Blundell
 

Más de Paul Blundell (12)

In 10 mins a software crafting journey
In 10 mins a software crafting journeyIn 10 mins a software crafting journey
In 10 mins a software crafting journey
 
The Novoda Craft University
The Novoda Craft UniversityThe Novoda Craft University
The Novoda Craft University
 
Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid Foundations
 
Http Caching for the Android Aficionado
Http Caching for the Android AficionadoHttp Caching for the Android Aficionado
Http Caching for the Android Aficionado
 
My perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsMy perspective on MVP and architecture discussions
My perspective on MVP and architecture discussions
 
Java Patterns - Strategy
Java Patterns - StrategyJava Patterns - Strategy
Java Patterns - Strategy
 
Google I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsGoogle I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech Announcements
 
Android Jam - Services & Notifications - Udacity Lesson 6
Android Jam - Services & Notifications - Udacity Lesson 6 Android Jam - Services & Notifications - Udacity Lesson 6
Android Jam - Services & Notifications - Udacity Lesson 6
 
Android Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cAndroid Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4c
 
Android Jam - ContentProviders - Udacity Lesson 4b
Android Jam - ContentProviders - Udacity Lesson 4bAndroid Jam - ContentProviders - Udacity Lesson 4b
Android Jam - ContentProviders - Udacity Lesson 4b
 
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4aAndroid Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
 
Jenkins project based authorization
Jenkins   project based authorizationJenkins   project based authorization
Jenkins project based authorization
 

Último

How to Create Manifest File in Odoo 17 ERP
How to Create Manifest File in Odoo 17 ERPHow to Create Manifest File in Odoo 17 ERP
How to Create Manifest File in Odoo 17 ERPCeline George
 
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ ProjectSocial Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ ProjectApostolos Syropoulos
 
Nurdinova-Domestic Violence presentation
Nurdinova-Domestic Violence presentationNurdinova-Domestic Violence presentation
Nurdinova-Domestic Violence presentationTom Tresser
 
CRYOTHERAPY BY DR. ANERI PATWARI.. .pptx
CRYOTHERAPY BY DR. ANERI PATWARI.. .pptxCRYOTHERAPY BY DR. ANERI PATWARI.. .pptx
CRYOTHERAPY BY DR. ANERI PATWARI.. .pptxAneriPatwari
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxvidhisharma994099
 
Natural Numbers, Whole Numbers, Integers.pdf
Natural Numbers, Whole Numbers, Integers.pdfNatural Numbers, Whole Numbers, Integers.pdf
Natural Numbers, Whole Numbers, Integers.pdfPranav Sharma
 
Preparing for the FDA’s Enforcement of the Intentional Adulteration Rule
Preparing for the FDA’s Enforcement of the Intentional Adulteration RulePreparing for the FDA’s Enforcement of the Intentional Adulteration Rule
Preparing for the FDA’s Enforcement of the Intentional Adulteration RuleSafetyChain Software
 
LANGUAGE AND BRAIN :Relationship Between Language and the Brain
LANGUAGE AND BRAIN :Relationship Between Language and the BrainLANGUAGE AND BRAIN :Relationship Between Language and the Brain
LANGUAGE AND BRAIN :Relationship Between Language and the BrainImran Kakar
 
class 8 geography chapter no.1 resources
class 8 geography chapter no.1 resourcesclass 8 geography chapter no.1 resources
class 8 geography chapter no.1 resourcesnaminabibi33
 
Teaching English to the Test: Why Does Negative Washback Exist within Seconda...
Teaching English to the Test: Why Does Negative Washback Exist within Seconda...Teaching English to the Test: Why Does Negative Washback Exist within Seconda...
Teaching English to the Test: Why Does Negative Washback Exist within Seconda...Adduha3
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlDr. Bruce A. Johnson
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...M56BOOKSTORE PRODUCT/SERVICE
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptxmary850239
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
Empowering Student Engagement with Open Education
Empowering Student Engagement with Open EducationEmpowering Student Engagement with Open Education
Empowering Student Engagement with Open EducationLorna Campbell
 
MS4 -seq3- citizenship& community lexis & conditional 1& imperative & text ...
MS4 -seq3-  citizenship& community lexis & conditional 1&  imperative & text ...MS4 -seq3-  citizenship& community lexis & conditional 1&  imperative & text ...
MS4 -seq3- citizenship& community lexis & conditional 1& imperative & text ...Mr Bounab Samir
 
To test decimal representation of rational Numbers.pdf
To test decimal representation of rational Numbers.pdfTo test decimal representation of rational Numbers.pdf
To test decimal representation of rational Numbers.pdfPranav Sharma
 
3.28.24 The Poor People's Campaign.pptx
3.28.24  The Poor People's Campaign.pptx3.28.24  The Poor People's Campaign.pptx
3.28.24 The Poor People's Campaign.pptxmary850239
 
Introduction to sun protection, classification of sunscreens and SPF
Introduction to sun protection, classification of sunscreens and SPFIntroduction to sun protection, classification of sunscreens and SPF
Introduction to sun protection, classification of sunscreens and SPFShraddhaGondhale
 
How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17Celine George
 

Último (20)

How to Create Manifest File in Odoo 17 ERP
How to Create Manifest File in Odoo 17 ERPHow to Create Manifest File in Odoo 17 ERP
How to Create Manifest File in Odoo 17 ERP
 
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ ProjectSocial Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
 
Nurdinova-Domestic Violence presentation
Nurdinova-Domestic Violence presentationNurdinova-Domestic Violence presentation
Nurdinova-Domestic Violence presentation
 
CRYOTHERAPY BY DR. ANERI PATWARI.. .pptx
CRYOTHERAPY BY DR. ANERI PATWARI.. .pptxCRYOTHERAPY BY DR. ANERI PATWARI.. .pptx
CRYOTHERAPY BY DR. ANERI PATWARI.. .pptx
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptx
 
Natural Numbers, Whole Numbers, Integers.pdf
Natural Numbers, Whole Numbers, Integers.pdfNatural Numbers, Whole Numbers, Integers.pdf
Natural Numbers, Whole Numbers, Integers.pdf
 
Preparing for the FDA’s Enforcement of the Intentional Adulteration Rule
Preparing for the FDA’s Enforcement of the Intentional Adulteration RulePreparing for the FDA’s Enforcement of the Intentional Adulteration Rule
Preparing for the FDA’s Enforcement of the Intentional Adulteration Rule
 
LANGUAGE AND BRAIN :Relationship Between Language and the Brain
LANGUAGE AND BRAIN :Relationship Between Language and the BrainLANGUAGE AND BRAIN :Relationship Between Language and the Brain
LANGUAGE AND BRAIN :Relationship Between Language and the Brain
 
class 8 geography chapter no.1 resources
class 8 geography chapter no.1 resourcesclass 8 geography chapter no.1 resources
class 8 geography chapter no.1 resources
 
Teaching English to the Test: Why Does Negative Washback Exist within Seconda...
Teaching English to the Test: Why Does Negative Washback Exist within Seconda...Teaching English to the Test: Why Does Negative Washback Exist within Seconda...
Teaching English to the Test: Why Does Negative Washback Exist within Seconda...
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting Bl
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Empowering Student Engagement with Open Education
Empowering Student Engagement with Open EducationEmpowering Student Engagement with Open Education
Empowering Student Engagement with Open Education
 
MS4 -seq3- citizenship& community lexis & conditional 1& imperative & text ...
MS4 -seq3-  citizenship& community lexis & conditional 1&  imperative & text ...MS4 -seq3-  citizenship& community lexis & conditional 1&  imperative & text ...
MS4 -seq3- citizenship& community lexis & conditional 1& imperative & text ...
 
To test decimal representation of rational Numbers.pdf
To test decimal representation of rational Numbers.pdfTo test decimal representation of rational Numbers.pdf
To test decimal representation of rational Numbers.pdf
 
3.28.24 The Poor People's Campaign.pptx
3.28.24  The Poor People's Campaign.pptx3.28.24  The Poor People's Campaign.pptx
3.28.24 The Poor People's Campaign.pptx
 
Introduction to sun protection, classification of sunscreens and SPF
Introduction to sun protection, classification of sunscreens and SPFIntroduction to sun protection, classification of sunscreens and SPF
Introduction to sun protection, classification of sunscreens and SPF
 
How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17
 

Oh so you test? - A guide to testing on Android from Unit to Mutation

  • 1. Oh you test? cool test bro
  • 3. - Define different types of testing - Clarify testing & naming - Benefits of each type of testing - Codez available to help you - Some architecture hints & tips Abstract
  • 4. Test Types - Unit Tests - Integration Tests - Functional Tests - Acceptance Tests - Mutation Tests - Vendor Tests - Fuzz Tests
  • 6. - Test a single block of code / function - Test independently from collaborators - Only test against interface definitions - New behaviour : new unit test Unit Tests - What
  • 7. @Test public void testGetLastPathSegmentReturnsFilename() { SecureUrl secureUrl = new SecureUrl( "http://test.com/some/random/url/filename.mp4"); String lastPathSegment = secureUrl.getLastPathSegment(); assertThat(lastPathSegment).isEqualTo("filename.mp4"); } Unit Tests - Example
  • 8. - Daily development work - Allow for continuous refactoring - Test Driven Development - Documentation for legacy developers Unit Tests - When
  • 9. Unit Tests - Where - All building blocks - All levels of an application architecture - Help pinpoint a place of failure
  • 11. - Highlight UI issues - Guarantee combined system integrity - Prove integration of components Unit Tests - Won’t
  • 12. - Interaction between two or more classes - Use real objects - Can use threads - Can access database Integration Tests - What
  • 13. @Test(expected = IllegalStateException.class) public void testFindFragmentWithUnknownTagResourceIdThrowsError() { Activity activity = Robolectric.buildActivity(Activity.class).get(); FragmentManager fM = activity.getFragmentManager(); Resources resources = activity.getResources(); TaskFragmentFinder finder = new TaskFragmentFinder(resources); finder.findTaskFragment(fM, UNKNOWN_TASK_ID); } Integration Tests - Example
  • 14. - Ensure parity of collaboration between objects - Testing expected changes - db schema - Testing environment integration Integration Tests - When
  • 15. - All building blocks - Interactions between layers - Help pinpoint integration issues Integration Tests - Where
  • 17. - Highlight UI issues - Show specific code block of failure - Give instant feedback - Hard to diagnose some failures - Full system confidence Integration Tests - Won’t
  • 18. - Whole system, nearly end to end - Don’t care about intermediary steps - Slower to run - Mostly controller driven Functional Tests - What
  • 19. public void testShowsFilmInformationAfterApiCallFinished() { String expectedTitle = "Swimming Pool"; startFilmActivity(); onData(is(instanceOf(Film.class))) .atPosition(FIRST) .onChildView(withId(R.id.film_text_view_title)) .check(matches(allOf(isDisplayed(), withText(equalToIgnoringCase(expectedTitle))))); } Functional Tests - Example
  • 20. - Evaluate expectation of sum of the parts - Confirming feature completion - TDD Keep you focused - Confidence in features of system Functional Tests - When
  • 21. - Span whole architecture - Touching live systems - Above integrated components Functional Tests - Where
  • 23. - Show specific broken units of code - Lack of knowledge of the details - Give quick feedback for specific problems Functional Tests - Won’t
  • 24. - Black box tests - From user perspective - Specialised form of functional tests - Model the final complete system Acceptance Tests - What
  • 25. public void testRotationInBrowseScreenMaintainsActionBar() { swipeToBrowseScreen(); Activity activity = rotate(this); assertActionBarOpen(activity); } private void assertActionBarOpen(Activity activity) { assertTrue("Expected ActionBar open but was closed.", activity.getActionBar().isShowing()); } Acceptance Tests - Example
  • 26. - User interface is integrated - TDD feedback loop - Capturing differences across devices - Screenshots for greater feedback Acceptance Tests - When
  • 27. - Span whole architecture - Touching live systems - Above integrated components Acceptance Tests - Where
  • 29. - Run very fast - No feedback upon cause (just symptoms) - Help day-to-day incremental improvements Acceptance Tests - Won’t
  • 30. - Mutate the state of your code - Insert faults in your software - Unit tests are ran - Tests fail “mutant is killed” thumbs up - Tests pass “mutant survived” thumbs down Mutation Tests - What
  • 32. Mutation Tests - Example if (a == b) { // do something } will be mutated to if (a != b) { // do something } Different Mutators: if (a == b) { // do something } will be mutated to if (true) { // do something } public int method(int i) { i++; return i; } will be mutated to public int method(int i) { i--; return i; }
  • 34. - Find holes in your test suite - Depends on % code coverage - Confidence in your unit tests - Complexity of your problem is high Mutation Tests - When
  • 35. - Outside of your code - Around your test suite - Not written yourself but configured - Configuration is key Mutation Tests - Where
  • 37. - Give any confidence in working software - Show collaboration between objects - Prove if the application actually works - Help at all without unit tests Mutation Tests - Won’t
  • 38. - can be unit, integration, functional - learn how 3rd party libraries work - confirming understanding - safety net for outside changes Vendor Tests - What
  • 39. @Test public void setAndGetActiveSessionAreTrustworthy() { Session.setActiveSession(mockFacebookSession); FacebookSession session = Session.getActiveSession(); assertThat(mockFacebookSession).isEqualTo(session); } Vendor Tests - Example
  • 40. - Incorporating 3rd party library - Not beneficial to add retrospectively - Replacing libraries with confidence - Wanting to ‘in house’ a library feature Vendor Tests - When
  • 41. - Around your 3rd party libraries - One off test - Suite inside unit tests Vendor Tests - Where
  • 43. - Confirm your domain code - Replace unit, integration or acceptance tests - Adds overhead to development Vendor Tests - Won’t
  • 44. - Feeding your software random data - Wait to see what breaks - It is not logical - Android = Application Exerciser Monkey - Combinatory with other tools Fuzz Tests - What
  • 45. adb shell monkey -p com.your.package.name -v 50000 Fuzz Tests - Example // Allowing start of Intent { act=mubi.intent.action.ON_BOARD cmp=com.mubi/.onboard.OnboardActivity } in package com. mubi :Sending Touch (ACTION_DOWN): 0:(1091.0,659.0) :Sending Touch (ACTION_UP): 0:(1085.1356,667.17145) :Sending Touch (ACTION_DOWN): 0:(467.0,404.0) :Sending Touch (ACTION_UP): 0:(472.5769,398.45746) // CRASH: com.mubi (pid 754) // Short Msg: java.lang.IllegalStateException // Long Msg: java.lang.IllegalStateException: Fragment WatchFragment{413d0d98} is not currently in the FragmentManager // Build Label: google/nakasi/grouper:4.1.1/JRO03H/405518:user/release-keys // Build Changelist: 405518 // Build Time: 1364293068000 // java.lang.IllegalStateException: Fragment WatchFragment{413d0d98} is not currently in the FragmentManager // at android.app.FragmentManagerImpl.saveFragmentInstanceState(FragmentManager.java:586) // at android.support.v13.app.FragmentStatePagerAdapter.destroyItem(FragmentStatePagerAdapter.java:140) // at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:413) // at com.mubi.onboard.OnboardActivity.updateViewPager(OnboardActivity.java:139) // at com.mubi.onboard.OnboardActivity.onRetrieved(OnboardActivity.java:132) // at com.mubi.onboard.OnboardTaskFragment$3.run(OnboardTaskFragment.java:77) // at android.os.Handler.handleCallback(Handler.java:725) // at android.os.Handler.dispatchMessage(Handler.java:92) // at android.os.Looper.loop(Looper.java:137) // at android.app.ActivityThread.main(ActivityThread.java:5195) // at java.lang.reflect.Method.invokeNative(Native Method) // at java.lang.reflect.Method.invoke(Method.java:511) // at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795) // at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562) // at com.android.internal.os.ZygoteInit.main(Native Method) // at dalvik.system.NativeStart.main(Native Method) // ** Monkey aborted due to error. Events injected: 4191
  • 46. - From the beginning - Thin slice (UI) - Continuous integration, faster feedback - Identifying differences across Android versions - Highlight refactoring effort Fuzz Tests - When
  • 47. - Black box testing - On top of your application (Android) - Custom fuzz testing - input level - Continuous integration Fuzz Tests - Where
  • 49. - Prove application is running correctly - Only reports crashes - Highlights quality rather than bugs - Not a replacement for unit, integration etc Fuzz Tests - Won’t
  • 50. Helpers / Libraries - Brief overview - What test types it benefits - Any positives - Any negatives
  • 51. Mockito //mock creation List mockedList = mock(List.class); //using mock object - doesn’t throw exceptions mockedList.add(“one”); //selective & explicit verification verify(mockList).add(“one”); Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with clean & simple API. Mockito doesn't give you a hangover because the tests are very readable and they produce clean verification errors. - Unit Tests : mocking dependencies - Integration Tests : questionable use
  • 52. Fest FEST is a collection of libraries, whose mission is to simplify software testing. No more confusion about the order of the "expected" and "actual" values. Our assertions are very readable as well: they read very close to plain English, making it easier for non-technical people to read test code. Regular JUnit: assertEquals(View.GONE, view.getVisibility()); Regular FEST: assertThat(view.getVisibility()).isEqualTo(View.GONE); FEST Android: assertThat(view).isGone(); - Unit Tests - Integration Tests - Functional Tests - Acceptance Tests : anywhere you do assertions improving readability
  • 53. “Robolectric is a unit test framework that de-fangs the Android SDK jar so you can test-drive the development of your Android app. Tests run inside the JVM on your workstation in seconds. “ Robolectric @RunWith(RobolectricTestRunner.class) public class ViewingQueryTaskTest { @Test public void testAlwaysClosesCursor() { viewingQueryTask.run(); verify(mockCursor).close(); } } - Unit tests : for day to day activity including TDD - Integration tests : to handle Android - Positive : speed vs on device tests - Negative : the rabbit hole
  • 54. “Robotium is an Android test automation framework. Robotium makes it easy to write powerful and robust automatic black-box UI tests. With the support of Robotium, test case developers can write functional and user acceptance test scenarios, spanning multiple Android activities.“ Robotium - Functional tests : check when you click a button the shared preferences are updated - Acceptance tests : ensure features have been completed and take screenshots for feedback public class EditorTest extends ActivityInstrumentationTestCase2<EditorActivity> { private Solo solo; public void setUp() throws Exception { solo = new Solo(getInstrumentation(), getActivity()); } public void testFileExtensionIsInMenu() { solo.sendKey(Solo.MENU); solo.clickOnText("More"); solo.clickOnText("Preferences"); solo.clickOnText("Edit File Extensions"); Assert.assertTrue(solo.searchText("rtf")); } }
  • 55. Use Espresso to write concise, beautiful, and reliable Android UI tests Espresso tests state expectations, interactions, and assertions clearly without the distraction of boilerplate content, custom infrastructure, or messy implementation details getting in the way. Espresso public void testSayHello() { onView(withId(R.id.name_field).perform(typeText("Dave")); onView(withId(R.id.greet_button)).perform(click()); onView(withText("Hello Dave!")).check(matches(isDisplayed())); } - Functional tests : check when you click a button the shared preferences are updated - Acceptance tests : ensure features have been completed, doesn’t support screenshots as an API but you can still do it http://tiny.cc/disableAnim http://tiny.cc/espressoScreenshot
  • 56. The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner. UI Exerciser Monkey adb shell monkey -p com.your.package.name -v 50000 - Fuzz tests : as already discussed allows you to test input events Don’t get the Application Exerciser Monkey & the Monkey Runner mixed up. App Ex Monkey – Fuzz Testing Monkey Runner – Android device control using Python scripts
  • 57. The uiautomator testing framework lets you test your user interface (UI) efficiently by creating automated functional UI testcases that can be run against your app on one or more devices. UI Automator extend UIAutomatorTestCase UIObject & UISelector Min SDK 16 Jelly Bean adb shell uiautomator runtest MyTests.jar -c com.example.MyApp Tests are in the jar, and the package is the package of the app under test. - Acceptance tests : acts just like a user.
  • 59. - Allows for separation of concerns - Java only module - Directed testing - Encapsulating change - Reuse Modules / Modularity Empowers
  • 60. - Readable & flexible CI builds - Flavors, build types - Swapping out whole components - Greater range of testing flexibility Gradle Empowers
  • 61. - Test reliability - Test speed - Data integrity Mock Services Empower
  • 62. - Hexagonal architecture - Insulates system from outside dependencies - Empowers testing - Disconnect from platform requirements Ports & Adapters Empower
  • 64. - Quality of your code reflects quality of your tests - Object Oriented programming lends itself to quality testing - TDD - Static methods are evil Low Code Quality Encumbers
  • 65. - Framework lock in - Google Play services - Android code examples - Activity life cycle Android (frameworks) Encumber
  • 66. - Believe in testing - Believe in clean code - Software craftsmanship - TDD - Be energetic - Enjoy it YOU Empower || Encumber
  • 67. Monkey Runner Spoon Jmock Hexagonal Architecture Contract Tests Others Groovy Tests Static analysis tools Charles cURL Postman Google sizes (small medium large)
  • 68. We are hiring developers
  • 69. Online Blogs Martin Fowler http://martinfowler.com/tags/testing.html JB Rainsberger http://blog.thecodewhisperer.com/ Kevin Rutherford http://silkandspinach.net/ Robert Martin https://sites.google.com/site/unclebobconsultingllc/blogs-by-robert-martin References More Info Android Fuzz Tests http://developer.android.com/tools/help/monkey.html Hardcore Fuzz Tests http://www.ibm.com/developerworks/library/j-fuzztest/index.html Vendor Tests https://www.youtube.com/watch?v=47nuBTRB51c#t=23m34s Mutation Tests http://pitest.org/ Google Testing Opinion http://googletesting.blogspot.co.uk/2010/12/test-sizes.html Mockito https://code.google.com/p/mockito/ Mocking Frameworks http://blogs.telerik.com/skimedic/posts/13-07-23/top-5-reasons-to-use-a-mocking-framework Android Fest https://github.com/square/fest-android Robolectric http://robolectric.org/ Robotium https://code.google.com/p/robotium/ Espresso https://code.google.com/p/android-test-kit/wiki/Espresso UI Automator http://developer.android.com/tools/help/uiautomator/index.html SOLID Principles http://www.its-on-the-internet-so-it-must-be-true.com/2012/06/solid-principles.html