All Projects → mannodermaus → Android Junit5

mannodermaus / Android Junit5

Licence: apache-2.0
Testing with JUnit 5 for Android.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Android Junit5

scalatest-junit-runner
JUnit 5 runner for Scalatest
Stars: ✭ 30 (-94.83%)
Mutual labels:  gradle-plugin, junit
gradle-console-reporter
Gradle plugin to report various kinds of summaries to console.
Stars: ✭ 49 (-91.55%)
Mutual labels:  gradle-plugin, junit
Gradle Android Junit Jacoco Plugin
Gradle plugin that generates JaCoCo reports from an Android Gradle Project
Stars: ✭ 315 (-45.69%)
Mutual labels:  gradle-plugin, junit
Docker Compose Rule
A JUnit rule to manage docker containers using docker-compose
Stars: ✭ 393 (-32.24%)
Mutual labels:  junit
Dependency Analysis Android Gradle Plugin
Gradle plugin for Java, Kotlin, and Android projects. Provides advice for managing dependencies and other applied plugins
Stars: ✭ 409 (-29.48%)
Mutual labels:  gradle-plugin
System Rules
A collection of JUnit rules for testing code which uses java.lang.System.
Stars: ✭ 492 (-15.17%)
Mutual labels:  junit
Gradle Git
Git plugin for Gradle
Stars: ✭ 559 (-3.62%)
Mutual labels:  gradle-plugin
Gradle Js Plugin
Gradle plugin for working with JS
Stars: ✭ 376 (-35.17%)
Mutual labels:  gradle-plugin
Testcontainers Java
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
Stars: ✭ 5,478 (+844.48%)
Mutual labels:  junit
Quicktheories
Property based testing for Java 8
Stars: ✭ 483 (-16.72%)
Mutual labels:  junit
Gradle Download Task
Adds a download task to Gradle that displays progress information
Stars: ✭ 478 (-17.59%)
Mutual labels:  gradle-plugin
Androidut
Android开发中必要的一环---单元测试(Unit Test)
Stars: ✭ 419 (-27.76%)
Mutual labels:  junit
Junit5
✅ The 5th major version of the programmer-friendly testing framework for Java and the JVM
Stars: ✭ 4,929 (+749.83%)
Mutual labels:  junit
Gradle Static Analysis Plugin
Easy setup of static analysis tools for Android and Java projects.
Stars: ✭ 398 (-31.38%)
Mutual labels:  gradle-plugin
Multi Os Engine
Multi-OS Engine: Create iOS Apps in Java (or Kotlin ... etc.)
Stars: ✭ 529 (-8.79%)
Mutual labels:  gradle-plugin
Androidautotrack
Android Asm 插桩 教学
Stars: ✭ 378 (-34.83%)
Mutual labels:  gradle-plugin
Can I Drop Jetifier
Gradle plugin that checks if there are dependencies using support library instead of AndroidX.
Stars: ✭ 520 (-10.34%)
Mutual labels:  gradle-plugin
Gradle Test Logger Plugin
A Gradle plugin for printing beautiful logs on the console while running tests
Stars: ✭ 460 (-20.69%)
Mutual labels:  gradle-plugin
Bnd
Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
Stars: ✭ 446 (-23.1%)
Mutual labels:  gradle-plugin
Laziertracker
本项目通过Android字节码插桩插件实现Android端无埋点(或自动埋点),并且支持根据配置文件实现业务数据的自动采集。
Stars: ✭ 485 (-16.38%)
Mutual labels:  gradle-plugin

android-junit5 CircleCI

Logo

A Gradle plugin that allows for the execution of JUnit 5 tests in Android environments using Android Gradle Plugin 3.5.0 or later.

How?

This plugin configures the unit test tasks for each build variant of a project to run on the JUnit Platform. Furthermore, it provides additional configuration options for these tests through a DSL attached to android.testOptions.

Instructions on how to write JUnit 5 tests can be found in their User Guide. Furthermore, this repository provides a small showcase of the functionality provided by JUnit 5 here.

Download

Kotlin
buildscript {
  dependencies {
    classpath("de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1")
  }
}
Groovy
buildscript {
  dependencies {
    classpath "de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1"
  }
}

Snapshots of the development version are available through Sonatype's snapshots repository.

Setup

Kotlin
plugins {
  id("de.mannodermaus.android-junit5")
}

dependencies {
  // (Required) Writing and executing Unit Tests on the JUnit Platform
  testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.1")
  testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.1")

  // (Optional) If you need "Parameterized Tests"
  testImplementation("org.junit.jupiter:junit-jupiter-params:5.7.1")

  // (Optional) If you also have JUnit 4-based tests
  testImplementation("junit:junit:4.13")
  testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.7.1")
}
Groovy
apply plugin: "de.mannodermaus.android-junit5"

dependencies {
  // (Required) Writing and executing Unit Tests on the JUnit Platform
  testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1"
  testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.1"

  // (Optional) If you need "Parameterized Tests"
  testImplementation "org.junit.jupiter:junit-jupiter-params:5.7.1"

  // (Optional) If you also have JUnit 4-based tests
  testImplementation "junit:junit:4.13"
  testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.7.1"
}

More information on Getting Started can be found on the wiki.

Requirements

The latest version of this plugin requires:

  • Android Gradle Plugin 3.5.0 or above
  • Gradle 6.1.1 or above

Instrumentation Test Support

There is experimental support for Android instrumentation tests, which requires some additional configuration & dependencies. Furthermore, because JUnit 5 is built on Java 8 from the ground up, its instrumentation tests will only run on devices running Android 8.0 (API 26) or newer. Older phones will skip the execution of these tests completely, marking them as "ignored".

To start writing instrumentation tests with JUnit Jupiter, make the following changes to your module's build script:

Kotlin
android {
  defaultConfig {
    // 1) Make sure to use the AndroidJUnitRunner, or a subclass of it. This requires a dependency on androidx.test:runner, too!
    testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    // 2) Connect JUnit 5 to the runner
    testInstrumentationRunnerArgument("runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder")
  }

  // 3) Java 8 is required
  compileOptions {
    setSourceCompatibility(JavaVersion.VERSION_1_8)
    setTargetCompatibility(JavaVersion.VERSION_1_8)
  }
}
dependencies {
  // 4) Jupiter API & Test Runner, if you don't have it already
  androidTestImplementation("androidx.test🏃1.2.0")
  androidTestImplementation("org.junit.jupiter:junit-jupiter-api:5.7.1")

  // 5) The instrumentation test companion libraries
  androidTestImplementation("de.mannodermaus.junit5:android-test-core:1.2.2")
  androidTestRuntimeOnly("de.mannodermaus.junit5:android-test-runner:1.2.2")
}
Groovy
android {
  defaultConfig {
    // 1) Make sure to use the AndroidJUnitRunner, or a subclass of it. This requires a dependency on androidx.test:runner, too!
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    // 2) Connect JUnit 5 to the runner
    testInstrumentationRunnerArgument "runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder"
  }

  // 3) Java 8 is required
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

dependencies {
  // 4) Jupiter API & Test Runner, if you don't have it already
  androidTestImplementation "androidx.test🏃1.2.0"
  androidTestImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1"

  // 5) The instrumentation test companion libraries
  androidTestImplementation "de.mannodermaus.junit5:android-test-core:1.2.2"
  androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.2.2"
}

The android-test-core artifact includes an extension point for the ActivityScenario API; more information on that can be found in the wiki.

Official Support

At this time, Google hasn't shared any immediate plans to bring first-party support for JUnit 5 to Android. The following list is an aggregation of pending feature requests:

Building Locally

This repository contains multiple modules, divided into two sub-projects. The repository's root directory contains build logic shared across the sub-projects, which in turn use symlinks to connect to the common build scripts in their parent folder.

  • instrumentation: The root folder for Android-based modules, namely the instrumentation libraries & a sample application. After cloning, open this project in Android Studio.
  • plugin: The root folder for Java-based modules, namely the Gradle plugin for JUnit 5 on Android, as well as its test module. After cloning, open this project in IntelliJ IDEA.

License

Copyright 2017-2021 Marcel Schnelle

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.

See also the full License text.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].