Everyone knows you need testing, but what are the different types of testing, how will each type benefit you and what libraries are available to ease the pain? This talk will run through an explanation of each type of testing (unit, integration, functional, acceptance, fuzz, mutation...) explaining upon each level of an Android app, the testing involved, how this will benefit you and how it will benefit your users. It will also explain the architecture of a well tested app. Finally ending with some examples and libraries that ease your accessibility into testing and help with faster more descriptive feedback.
A short presentation slide deck I gave to interns we have this summer of 2019 on (unit) testing in software development. This is not a code-centric slide deck and just looking at the slides loses some context without being there in person, or having discussions, etc.
Principles and patterns for test driven developmentStephen Fuqua
Developed to help introduce key topics in Test Driven Development, for new and veteran developers alike. Some examples are language-specific (C# / MSTest / Moq), but the principles apply to any object oriented language.
This presentation describes the some of the major functionality of JUnit4 and TestNG .Each topic contains example so that a viewer can understand the usage and apply them in their code.
A brief introduction about the art of unit test, how to test a class, mock a collaborator and use a fake database. TDD is introduced. Code for exercises is available on github along with a detailed explanation. Examples and exercises are written in Java.
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...Thomas Weller
Intro to the MSTest framework (aka. Visual Studio Unit Testing), some additional tools (e.g. Moq, Moles, White), how this is supported in Visual Studio, and how it integrates into the broader context of the TFS environment.
A short presentation slide deck I gave to interns we have this summer of 2019 on (unit) testing in software development. This is not a code-centric slide deck and just looking at the slides loses some context without being there in person, or having discussions, etc.
Principles and patterns for test driven developmentStephen Fuqua
Developed to help introduce key topics in Test Driven Development, for new and veteran developers alike. Some examples are language-specific (C# / MSTest / Moq), but the principles apply to any object oriented language.
This presentation describes the some of the major functionality of JUnit4 and TestNG .Each topic contains example so that a viewer can understand the usage and apply them in their code.
A brief introduction about the art of unit test, how to test a class, mock a collaborator and use a fake database. TDD is introduced. Code for exercises is available on github along with a detailed explanation. Examples and exercises are written in Java.
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...Thomas Weller
Intro to the MSTest framework (aka. Visual Studio Unit Testing), some additional tools (e.g. Moq, Moles, White), how this is supported in Visual Studio, and how it integrates into the broader context of the TFS environment.
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
THE CHALLENGE:
Given you understand the value of test automation.
Given you are handed a legacy application to maintain and enhance
Given the application is in ASP.Net Web Forms
When you try to add tests
Then you find that test-driven development is literally impossible.
Software testing
Developers Belief on Software Testing
Developers Responsibility for testing
Test writing methods
State based testing
Behavioural/interaction based testing
Writing a Testable Code
Flaw 1 - Constructor does Real Work
Flaw 2 - API lies about it's real dependencies
Flaw 3 - Brittle Global State & Singletons
Testing Frameworks and tools for Java...
Mockito and PowerMock...
Testing Models
Stubs Based Testing Model
Mocked Objects Based Testing Model
JUit 4.+ and TestNG
https://www.adroitlogic.com
https://developer.adroitlogic.com
The presentation contains a definition and survey of the benefits of Unit Testing, and a little coding example to get the feeling of Unit Testing using JUnit, EasyMock and XMLUnit.
Integrate the Microsoft Unit Testing Framework into your Visual Studio 2010 projects. Learn the fundamentals of the Microsoft.VisualStudio.TestTools.UnitTesting namespace. Explore the tools for running and debugging your unit tests. Discuss general best practices for writing unit tests. Examples will be presented in C#.
Testing for Android: When, Where, and How to Successfully Use Test AutomationTrent Peterson
A high-level overview of test automation on the Android platform, beginning with a brief intro to software testing, how mobile isn't all that different from problems faced in the past, a tour of the most popular free tools available, and some words of advice.
The slides accompanied a talk presented at the San Francisco Android User Group on October 29, hosted at Twitter.
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
THE CHALLENGE:
Given you understand the value of test automation.
Given you are handed a legacy application to maintain and enhance
Given the application is in ASP.Net Web Forms
When you try to add tests
Then you find that test-driven development is literally impossible.
Software testing
Developers Belief on Software Testing
Developers Responsibility for testing
Test writing methods
State based testing
Behavioural/interaction based testing
Writing a Testable Code
Flaw 1 - Constructor does Real Work
Flaw 2 - API lies about it's real dependencies
Flaw 3 - Brittle Global State & Singletons
Testing Frameworks and tools for Java...
Mockito and PowerMock...
Testing Models
Stubs Based Testing Model
Mocked Objects Based Testing Model
JUit 4.+ and TestNG
https://www.adroitlogic.com
https://developer.adroitlogic.com
The presentation contains a definition and survey of the benefits of Unit Testing, and a little coding example to get the feeling of Unit Testing using JUnit, EasyMock and XMLUnit.
Integrate the Microsoft Unit Testing Framework into your Visual Studio 2010 projects. Learn the fundamentals of the Microsoft.VisualStudio.TestTools.UnitTesting namespace. Explore the tools for running and debugging your unit tests. Discuss general best practices for writing unit tests. Examples will be presented in C#.
Testing for Android: When, Where, and How to Successfully Use Test AutomationTrent Peterson
A high-level overview of test automation on the Android platform, beginning with a brief intro to software testing, how mobile isn't all that different from problems faced in the past, a tour of the most popular free tools available, and some words of advice.
The slides accompanied a talk presented at the San Francisco Android User Group on October 29, hosted at Twitter.
Yonaan Kay uploads presentation by Yonatan Kay's father on justice. This presentation ws not created by Yonatan Kay but he has full permission to upload this to Yonatan Kay slideshare space
Releasing a great app is more than having a unique idea. It takes teamwork, collaboration and the will to be the best. At Novoda we make awesomeness happen. This talk is about our process from coding dojos to group design and iterative sprint planning with our customers. We'll describe some of our best practices as well as some of the components that can make a good app great.
This includes:
- Day-to-day processes: pairing tennis, gif code reviews and toggling hidden features.
- Work Environment: hack & tells, continuous communication & kicking ass at Tekken.
- Releasing the app: polishing & quantifying can get you top of the class and not listening to Google can get you expelled.
Finishing with some bonus Android coding tips and tricks and crazy AOSP anti-patterns.
Entrepreneurship and business are two crucial factors for the growth of a nation.How we can drive it in more local way to grow in a global fashion.Local perspective and market interaction guide for an entrepreneur.
Go to http://broadsales.com
A deep dive into Jenkins Continuos Integration, how you can enable your team to collaborate more, run tests and configure the robots to do all the things for you. Also talking about caveats around automation, testing on real devices, usb hub woes and more.
This talk is a brief overview of how we deal with UI test architecture on our project. Complex backend, SPA as a frontend, 20+ different brands and 100+ features for each, more and more code.
We will discuss:
– fakes and test doubles, approaches how to build and maintain them;
– development patterns, which help you to make your architecture more simple, stable and readable;
– tips and tricks – how to make your life with UI tests easier.
Test-Driven Development is about approaching software development from a test perspective and knowing how to use the tools (e.g. JUnit, Mockito) to effectively write tests.
Source code examples @...
https://github.com/codeprimate-software/test-driven-development
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Comunidade NetPonto
Os Testes são cada vez mais uma necessidade nos projectos de desenvolvimento de software... Sejam eles unitários, de carga ou de "User Interface", uma boa framework de testes ajuda a resolver os problemas mais cedo, de forma mais eficaz e mais barata.
No final da sessão vamos perceber não só para que servem, como são feitos e como o Visual Studio 2010 pode ajudar.
This was a workshop given on the UTN University, for the Software Engineering students. The idea is to give a brief explanation about TDD, and how to use it.
Unit tests give developers and testers a quick way to look for logic errors in the methods of classes in Visual C#, Visual Basic, and Visual C++ projects. A unit test can be created one time and run every time that source code is changed to make sure that no bugs are introduced.
This workshop is about testing the right way. Get a clear view on how to test your code in an efficient and useful way!
This first testing-related workshop is about all aspects of unit testing. Integration testing and TDD will have their own dedicated workshops.
What is software crafting and software craftsmanship, how does it relate to you and your career. This is a lightening talk based on the longer variant given at various conferences.
The journey of a craftsperson is difficult and never-ending, full of hard work, sweat, and tears but it is also a journey of joy, discovery, knowledge acquisition, and professional growth.
We’ve created Novoda Craftsmanship University (NCU) so that employee's can take this journey together.
In this talk Paul Blundell will show how you can apply principles of craftsmanship to complex & iterative mobile Android & iOS products and how mobile craftspeople develop together and share knowledge at Novoda through the NCU.
Android Things is Googles latest foray into the Internet of Things. Android Things lets you build professional, mass-market products on a trusted platform, without previous knowledge of embedded system design. IoT devices need testing too.
We will talk about how to architect your Android Things applications to enable testing and explore best practices to keep your codebase clean and your IoT devices solid.
The second half of the talk will be a deeper dive into controlling Android Things peripherals. We'll explain what are user drivers, how they work, how to use them, and most importantly: how you can create and test a new driver from scratch that can be used from Android Things to interact with new peripherals.
Http Caching for the Android AficionadoPaul Blundell
Talk about how API caching works and what we expect our clients APIs to have in the best case and what we usually get.
Explaining how ETags work and Cache-Control is used. Touches a little on cache invalidation and rest level 3.
My perspective on MVP and architecture discussionsPaul Blundell
Talk about what MVP means to different people and how using MVP doesn't even matter. It's about the discussion.
I've hacked an app together with MVP, I want to show my findings and opinions about the most over defined term for a pattern ever.
The strategy pattern (also known as the policy pattern) is the creation of an inter-changeable family of algorithms interchangeable at run-time. This talk will give an overview of what that means and an attempt at a hands on example written in Java.
Google I/O 2015 Android & Tech AnnouncementsPaul Blundell
Explaining what went on at Google I/O 2015, what new announcements where made my Google with the release of Android M, their new API's, the technology around ATAP including Project Ara, Soli and Jacquard
Android Jam - Services & Notifications - Udacity Lesson 6 Paul Blundell
http://developerstudyjams.com/
Week 7 - Retrospectively looking at Udacity Lesson 6 Services & Notifications
Google Developers Study Jams is a free series of global, community-run, in-person study groups. The first Study Jams series is presented in partnership with Udacity and will follow their Android Fundamentals curriculum. Google Developer Group facilitators certified in the course will lead the Study Jams that meet once weekly for 8 - 9 weeks.
Promote using hashtag #devstudyjam
Android Jam - Loaders - Udacity Lesson 4cPaul Blundell
http://developerstudyjams.com/
Week 6 - Retrospectively looking at Udacity Lesson 4c Loaders
Google Developers Study Jams is a free series of global, community-run, in-person study groups. The first Study Jams series is presented in partnership with Udacity and will follow their Android Fundamentals curriculum. Google Developer Group facilitators certified in the course will lead the Study Jams that meet once weekly for 8 - 9 weeks.
Promote using hashtag #devstudyjam
Android Jam - ContentProviders - Udacity Lesson 4bPaul Blundell
http://developerstudyjams.com/
Week 6 - Retrospectively looking at Udacity Lesson 4b ContentProviders
Google Developers Study Jams is a free series of global, community-run, in-person study groups. The first Study Jams series is presented in partnership with Udacity and will follow their Android Fundamentals curriculum. Google Developer Group facilitators certified in the course will lead the Study Jams that meet once weekly for 8 - 9 weeks.
Promote using hashtag #devstudyjam
http://developerstudyjams.com/
Week 5 - Retrospectively looking at Udacity Lesson 4 Activity Lifecycle & Databases
Google Developers Study Jams is a free series of global, community-run, in-person study groups. The first Study Jams series is presented in partnership with Udacity and will follow their Android Fundamentals curriculum. Google Developer Group facilitators certified in the course will lead the Study Jams that meet once weekly for 8 - 9 weeks.
Promote using hashtag #devstudyjam
How to add project based jenkings authorisation on your build server. This shows the benefits and the caveats of using this approach to secure your build server projects so that people can only view what they are authorised to view.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
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
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
10.
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
16.
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
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
22.
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
28.
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
31.
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;
}
33.
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
36.
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
42.
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
48.
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.