Tuesday, March 06, 2012


Mockito: 
 
It lets you write beautiful tests with clean & simple API.

Mockito tests are very readable and they produce clean verification errors.


Some features:
1.) Mocks concrete classes as well as interfaces
2.) Little annotation syntax sugar - @Mock
3.) Verification errors are clean - click on stack trace to see failed verification in test; click on exception's cause to navigate to actual interaction in code. Stack trace is always clean.
4.) Allows flexible verification in order (e.g: verify in order what you want, not every single interaction)
5.) Supports exact-number-of-times and at-least-once verification
6.) Flexible verification or stubbing using argument matchers (anyObject(), anyString() or refEq() for reflection-based equality matching)
7.) Allows creating custom argument matchers or using existing hamcrest matchers

Distribution:
Single-jar distribution includes cglib, objenesis and source code
Zip distribution contains all jars, javadoc and source code


Unit Test Your Android Application (with Robolectric)

Thursday, March 01, 2012


Android Testing Framework Overview:


 

Working with Android Test Projects:



The testing framework has these key features:
  • Android test suites are based on JUnit. You can use plain JUnit to test a class that doesn't call the Android API, or Android's JUnit extensions to test Android components. If you're new to Android testing, you can start with general-purpose test case classes such as AndroidTestCase and then go on to use more sophisticated classes.  
  • The Android JUnit extensions provide component-specific test case classes. These classes provide helper methods for creating mock objects and methods that help you control the lifecycle of a component.
  • Test suites are contained in test packages that are similar to main application packages, so you don't need to learn a new set of tools or techniques for designing and building tests.
  • The SDK tools for building and tests are available in Eclipse with ADT, and also in command-line form for use with other IDES. These tools get information from the project of the application under test and use this information to automatically create the build files, manifest file, and directory structure for the test package.
  • The SDK also provides monkeyrunner, an API testing devices with Python programs, and UI/Application Exerciser Monkey, a command-line tool for stress-testing UIs by sending pseudo-random events to a device.