Gradle + Android Studio + Robolectric + Espresso + Mockito + EasyMock/PowerMock + JaCoCo
- Multiple Modules
- Multiple Flavors
- Android Libraries
Name | Version | Description |
---|---|---|
Gradle | v2.4 | Gradle build system |
Android Gradle Build Tools | v1.2.3 | Official Gradle Plugin |
Android SDK | v22 | Official SDK |
Android SDK Build Tools | v22.0.1 | Official Build Tools |
Android Studio or | v1.2+ | Official IDE |
Intellij | v14.1.3+ | Intellij IDE |
####Android Libraries:
Name | Version | Description |
---|---|---|
Android Support-v4 | v22.0.1 | Support Library API 4+ |
Android AppCompat-v7 | v22.0.1 | Support Library API 7+ |
Android Google Play Services | v7.3.0 | Admob, Analytics, etc |
####Testing Frameworks:
Name | Version | Description |
---|---|---|
JUnit | v4.12 | Java Unit Testing Framework |
Hamcrest | v1.3 | Matchers for Unit Tests |
Espresso | v2.1 | Google's New Instrumentation Framework |
Robolectric | v3.0-RC3 | Best Unit Testing Framework for Android |
Mockito | v1.10.19 | Mocking Framework |
EasyMock | v3.3.1 | Mocking Framework |
PowerMock | v1.6.2 | Mocking Framework(can handle static methods) |
####Reporting Plugins:
Name | Version | Description |
---|---|---|
JaCoCo | v0.7.4.201502262128 | JaCoCo Test Coverage |
Coveralls | N/A | Hosts test reports published from TravisCI |
####Continuous Integration:
Name | Description |
---|---|
TravisCI | Build Server(Builds, Tests, Publishes reports to Coveralls) |
- View JUnit and Hamcrest Tests
- View Robolectric Activity Tests
- View Robolectric Fragment Tests
- View EasyMock/PowerMock Tests
- Import/Open this project with Android Studio/Intellij(click on
build.gradle
) - Change the Build Variant Test Artifact to
Unit Tests
instead ofInstrumentation Tests
- Right click a unit test located in
src/main/test
and click test
git clone https://github.com/jaredsburrows/AndroidGradleTemplate.git
cd AndroidGradleTemplate
- Install the
debug flavor
on your Android Device:gradlew installDebug
- Install and Run the
debug flavor
on your Android Device:gradlew runDebug
- Run all tests in all
flavors
:gradlew test
- Run single test in all
flavors
:gradlew test --tests="*MainActivityTest*"
- Run all the
debug flavor
tests:gradlew testDebug
- Run single test in the
debug flavor
:gradlew testDebug --tests="*MainActivityTest*"
- Run single test in the
debug flavor
withJacoco
test reports:gradlew testDebug --tests="*MainActivityTest*" jacocoTestReport
Copyright (C) 2015 AndroidGradleTemplate by Jared Burrows
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.