boes-matt / TestProject

Sample Gradle project structure with tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test Project

Test Project is an example of a Gradle-based, Android Studio project structure with regular Android tests, Espresso tests, and JVM JUnit 4 tests.

Outline

Packages

com.boes.testproject.app: main app package located at app/src/main
Package includes 2 activities, a content provider, and a service to test.

com.boes.testproject.app.test: Android-specific test package located at app/src/androidTest
Tests use both the stock Android testing framework and Espresso.

com.boes.testproject.core: Java library package located at core/src/main
It is for application code that does not rely on the Android framework.

com.boes.testproject.core.test: Java library test package located at core/src/test
It contains tests that run on the JVM.

Gradle

  • Espresso is set up in app/build.gradle using Jake Wharton's Double Espresso tool

  • See Double Espresso README about any dependency exclusions needed in build.gradle for your project

  • This project excludes the support library in its androidTestCompile because it's already included from the compile dependencies in app/build.gradle

  • Set the testInstrumentationRunner in the defaultConfig to GoogleInstrumentationTestRunner in app/build.gradle

  • Exclude LICENSE.txt within packagingOptions in app/build.gradle

  • Add the Android-independent, core package library as a compile dependency in app/build.gradle

Set up Android Studio run configurations

  • app: Runs the app

  • App Tests: Runs Android-dependent tests in com.boes.testproject.app.test on device
    Specify instrumentation runner as GoogleInstrumentationTestRunner in setup. Find by including non-project classes in search.

  • Core Tests: Runs independent Java tests in com.boes.testproject.core.test on development machine
    Package contains JUnit 4 style test cases.

About

Sample Gradle project structure with tests


Languages

Language:Java 91.9%Language:Groovy 8.1%