Maven: The Complete Reference - 14.14. Testing Android Application Code |
|
Testing Android Application code can be done in a unit test fashion with rich junit support as part of the Android SDK as well as integration type testing called instrumentation testing. The Android Maven Plugin includes the execution of the Surefire plugin
and as such unit tests can be included in the project like in any
other project. The default path for test classes in the Eclipse and
therefore Android Development Toolkit is Adding the test folder to the build configuration. <build> <testSourceDirectory>test</testSourceDirectory> ...
Alternatively the Maven conventions can be implemented by moving the
source code for the application and the test source code into
Instrumentation tests are integration tests bundled into an application that run on the emulator or device and interact with another deployed application to test the behaviour. The common setup to run instrumentation tests would be two parallel projects, one for the application and one for the instrumentation tests. These modules are tied together as modules of a parent pom. The Android Maven Plugin samples contains the morseflash as well as
theapidemos-15 examples for a project set up in this manner. The setup
of the instrumentation test application with the Android Maven Plugin
is the same as for a normal application with the added dependency to
the application that needs to be tested. It is important to add the
<dependency> <groupId>com.simpligility.android</groupId> <artifactId>intents</artifactId> <version>0.1</version> <type>apk</type> </dependency> Instrumentation test execution supports a large number of configuration parameters that are displayed in the plugin configuration layout in Available parameters for instrumentation testing. Available parameters for instrumentation testing. <test> <skip>true|false|auto</skip> <instrumentationPackage>packageName</instrumentationPackage> <instrumentationRunner>className</instrumentationRunner> <debug>true|false</debug> <coverage>true|false</coverage> <logonly>true|false</logonly> avd <testsize>small|medium|large</testsize> <createreport>true|false</createreport> <classes> <class>your.package.name.YourTestClass</class> </classes> <packages> <package>your.package.name</package> </packages> </test>
Unless |