How to test Android with Gradle + Android Studio + Robolectric + Mockito + EasyMock/PowerMock + JaCoCo + TravisCI
Here is my Github example:
Clone with
Installing/Running with
Testing with
Here is my Github example:
https://github.com/jaredsburrows/AndroidGradleTemplate
AndroidGradleTemplate
Gradle + Android Studio + Robolectric + Mockito + EasyMock/PowerMock + JaCoCoTechnologies used:
- Building:
- Libraries:
- Testing:
- Reporting:
- Continuous Integration:
Works with the following Configurations:
- Multiple Modules
- Multiple Flavors
- Android Libraries
Getting Started:
- View JUnit and Hamcrest Tests
- View Robolectric Activity Tests
- View Robolectric Fragment Tests
- View EasyMock/PowerMock Tests
Android Studio
or Intellij
Support(Simple):
- Import/Open this project with Android Studio/Intellij(click on
build.gradle
) - Change the Build Variant Test Artifact to
Unit Tests
instead ofInstrumentation Tests
Comand Line(Advanced):
Clone with Git
:
git clone https://github.com/jaredsburrows/AndroidGradleTemplate.git
cd AndroidGradleTemplate
Installing/Running with Gradle
:
- Install the
debug flavor
on your Android Device:gradlew installDebug
- Install and Run the
debug flavor
on your Android Device:gradlew runDebug
Testing with Gradle
:
- 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
License
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.
No comments:
Post a Comment
Please make suggestions :)