Skip to content
RetroHack edited this page Feb 22, 2015 · 14 revisions

In order to properly test, there are a number of tools that we should be familiar with.

All the tools listed use JUnit.

Tools

Robolectric

Robolectric is used to mock out Android, allowing you to run unit tests off of JVM.

JUnit4

Robolectric tests are written in JUnit4

JUnit3
Robotium

Robotium allows you to simulate actions. It's mainly used for UI and integration testing.

Good link:http://www.vogella.com/tutorials/Robotium/article.html

Building Tests

Unit Tests

JUnit4
Robolectric
  • filenames should follow *Test.java format so the tests can be executed automatically

Integration Tests

JUnit3
Robotium
  • filenames should follow *IT.java format so the tests can be executed automatically

Running Tests

Unit Tests

Run unit tests on JVM

  • Linux: ./gradlew test

  • Windows: gradlew.bat test

Run unit tests with code coverage report.

  • Linux: ./gradlew jacocoTestReport

  • Windows: gradlew.bat jacocoTestReport

Integration Tests

To run integration tests, first make sure an android device is available for the tests to be run on. Whether that's an emulated or connected device is up to you. After that, run:

  • Linux: ./gradlew connectedAndroidTest

  • Windows: gradlew.bat connectedAndroidTest

Note: If you want more information on which specific tests passed/failed, use --info.

Jenkins

The Jenkins server is located at: 10.81.30.17:8080, and can only be accessed at the university. If you need to access it from elsewhere, you can do so through the University VPN.

Clone this wiki locally