Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Do you really want to delete this prezi?
Neither you, nor the coeditors you shared it with will be able to recover it again.
Make your likes visible on Facebook?
You can change this under Settings & Account at any time.
Transcript of Android Testing
Traceview Test Structure Strict Mode: What about spawned threads? Just a note Watching Strict Mode Test projects are organized into a standard structure of tests, test case classes, and test packages
Test cases are generated for the different components of the application under test
In Android you use the test tools to load the test packages and the application under test. The tools then execute the Android-specific test runner is a new API in Gingerbread which primarily lets you:
set a policy on a thread
declaring what you’re not allowed to do on that thread
and what the penalty is if you violate the policy per-thread policies are propagated whenever Binder IPC calls are made to other Services or Providers, and stack traces are stitched together across any number of processes. Can't depend on the flash component and filesystem of most Android devices to be consistently fast
The YAFFS filesystem has a global lock around all its operations. using penaltyLog()
the default, just run adb logcat and watch the terminal output.
Any violations will be logged to your console
written to the DropBoxManager, where you can extract it later with
adb shell dumpsys dropbox data_app_strictmode --print Traceview Used for performance improvement and profiling Analyze Traceview For standard Java we use JUnit
For Android components we use Android's JUnit extension
Test suites are contained in test packages; A test package is auto generated VIA the SDK tools for building and testing
The SDK also provides monkeyrunner and UI/Application Exerciser Monkey Testing Fundamentals Overview Overview of testing fundamentals
Short demo on Activity testing
Look at StrictMode and Traceview Test Projects Tests are organized into projects Use the Android-tools to create test projects as there are benefits:
It automatically sets up your test package to use InstrumentationTestRunner as the test case runner
It creates an appropriate name for the test package
It automatically creates the proper build files, manifest file, and directory structure for the test project Testing API JUnit
Component-specific test cases
Mock objects Android JUnit Testing Use AndroidTestCase to test Android-dependant objects - provides Android specific setup, teardown, and helper methods
Android provides a class of assertions that extend the possible types of comparisons - Also assertion classes for testing the UI
Note that the Android testing API supports JUnit 3 code style, but not JUnit 4 Instrumentation Instrumentation allows you to control the life cycle of Android Activities You can invoke callback methods step-by-step in your test code
Instrumentation can load both a test package and the application under test into the same process
Grants access to methods and fields of the component being tested Assertion classes Component-specific test cases Mock Objects There are component-specific test classes for Activities, Content Providers, and Service
These address specific component testing needs with methods for fixture setup and teardown and component lifecycle control Using Assertions can be more convenient then doing logging MoreAsserts - contains more powerful assertions such as such as assertion to do regular expression matching
ViewAsserts - Used to test views such as assertHasScreenCoordinate to test if a coordinate is available on the visible screen Facilitate dependency injection There are mock objects for Context, ContentProvider, ContentResolver and Service objects Used to isolate tests from the rest of the system Normal application operations are stubbed out
Stubbed out methods throw UnsupportedOperationException when called unless a method is explicitly overridden DEMO Turn traceview on View the trace Thank you