Gradle + Android Studio + Robolectric + Espresso + Mockito + EasyMock/PowerMock + JaCoCo
- Multiple Modules
- Multiple Flavors
- Android Libraries
Name | Version | Description |
---|---|---|
Gradle | 2.4 | Gradle build system |
Android Gradle Build Tools | 1.2.3 | Official Gradle Plugin |
Android SDK | 22 | Official SDK |
Android SDK Build Tools | 22.0.1 | Official Build Tools |
Android Studio or | 1.2+ | Official IDE |
Intellij | 14.1.3+ | Intellij IDE |
####Android Libraries:
Name | Version | Description |
---|---|---|
Android Support-v4 | 22.0.1 | Support Library API 4+ |
Android AppCompat-v7 | 22.0.1 | Support Library API 7+ |
Android Google Play Services | 7.3.0 | Admob, Analytics, etc |
####Testing Frameworks:
Name | Version | Description |
---|---|---|
JUnit | 4.12 | Java Unit Testing Framework |
Hamcrest | 1.3 | Matchers for Unit Tests |
Espresso | 2.1 | Google's New Instrumentation Framework |
Robolectric | 3.0-RC3 | Unit Testing Framework |
Mockito | 1.10.19 | Mocking Framework |
EasyMock | 3.3.1 | Mocking Framework |
PowerMock | 1.6.2 | Mocking Framework(static method support) |
####Reporting Plugins:
Name | Version | Description |
---|---|---|
JaCoCo | 0.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) |
####Publishing to Google Play:
Name | Version | Description |
---|---|---|
Gradle-play-publisher | 1.1.0 | Publishes your app to Google Play |
- 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
) -
Instrumentation Tests:
-
Change the Build Varient Test Artifact to
Instrumentation Tests
-
Right click an instrumentation test located in
src/main/androidTest
and click test -
Unit Tests:
-
Change the Build Variant Test Artifact to
Unit 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 instrumentation tests in all
flavors
:gradlew connectedAndroidTest
- Run all unit tests in all
flavors
:gradlew test
- Run a single unit test in all
flavors
:gradlew test --tests="*MainActivityTest*"
- Run all unit
debug flavor
tests:gradlew testDebug
- Run a single unit test in the
debug flavor
:gradlew testDebug --tests="*MainActivityTest*"
- Run a single unit 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.