All Projects → cortinico → rules4android

cortinico / rules4android

Licence: MIT License
A collection of JUnit 4 Rules for Android Developers 🔬

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to rules4android

jest-retry
Jest retry pattern for flaky E2E tests
Stars: ✭ 36 (+56.52%)
Mutual labels:  flaky-tests, flaky
ui-testing
No description or website provided.
Stars: ✭ 15 (-34.78%)
Mutual labels:  android-tests, android-testing
kafka-junit
JUnit rule for spinning up a Kafka broker
Stars: ✭ 97 (+321.74%)
Mutual labels:  junit, junit-rule
Bundletool
Bundletool is a command-line tool to manipulate Android App Bundles
Stars: ✭ 2,440 (+10508.7%)
Mutual labels:  android-development, android-testing
Github-Search
https://medium.com/@ericntd/the-real-beginner-guide-to-android-unit-testing-3859d2f25186
Stars: ✭ 18 (-21.74%)
Mutual labels:  junit4, android-testing
justtestlah
Dynamic test framework for web and mobile applications
Stars: ✭ 43 (+86.96%)
Mutual labels:  junit, junit4
scalatest-junit-runner
JUnit 5 runner for Scalatest
Stars: ✭ 30 (+30.43%)
Mutual labels:  junit, junit-test
doc
QuickPerf documentation: https://github.com/quick-perf/doc/wiki/QuickPerf
Stars: ✭ 22 (-4.35%)
Mutual labels:  junit, junit-test
Debt-Manager
A personal app to store people that owe you money or you owe money to. "Mo Money Mo Problems" 🎵 - The Notorious B.I.G. 😎
Stars: ✭ 22 (-4.35%)
Mutual labels:  android-development, junit
jbehave-junit-runner
Integrate JBehave better with JUnit. Reports all Stories, Scenarios and Steps as JUnit Suites and Test Cases.
Stars: ✭ 70 (+204.35%)
Mutual labels:  junit, junit4
timber-junit-rule
A highly configurable JUnit Rule that outputs Timber logs to standard output
Stars: ✭ 42 (+82.61%)
Mutual labels:  junit, junit-test
parameterized-suite
Provides a new Runner for JUnit 4 that combines the features of Suite and Parameterized
Stars: ✭ 19 (-17.39%)
Mutual labels:  junit, junit4
ForgeModdingSkeleton
Skeletons for building Forge mods
Stars: ✭ 21 (-8.7%)
Mutual labels:  junit, junit4
FragmentTestRule
JUnit Rule to test a Fragment in isolation
Stars: ✭ 102 (+343.48%)
Mutual labels:  junit-rule, android-testing
osgi-test
Testing support for OSGi. Includes JUnit 4 and JUnit 5 support and AssertJ support.
Stars: ✭ 22 (-4.35%)
Mutual labels:  junit, junit4
dev-alert-android
This lightweight library provides visual alerts to developers and QA when an issue happens during development/testing phase.
Stars: ✭ 78 (+239.13%)
Mutual labels:  android-development
android-jetpack
🚀 Road to Accelerate Android Development using Jetpack
Stars: ✭ 50 (+117.39%)
Mutual labels:  android-development
Android-Diagonal-Cut-View
learnyandroid.blogspot.com/2017/11/create-diagonal-cut-view-in-android.html
Stars: ✭ 14 (-39.13%)
Mutual labels:  android-development
AndroidDevTools
收集整理Android开发所需的Android SDK、开发中用到的工具、Android开发教程、Android设计规范,免费的设计素材等。
Stars: ✭ 7,284 (+31569.57%)
Mutual labels:  android-development
webdrivermanager-examples
JUnit tests with Selenium WebDriver and WebDriverManager
Stars: ✭ 94 (+308.7%)
Mutual labels:  junit

@Rules 4 Android

CircleCI Download License Twitter

A collection of JUnit Rules that can be helpful to Android Developers. Do you have any idea for a JUnit rule that could be helpful for everyone? Feel free to open an Issue or a Pull request!

This repo contains the source code related to this article: Don't be lazy, use @Rules.

Getting Started 👣

rules4android is distributed through JCenter. To use it you need to add the following Gradle dependency to your android app gradle file (NOT the root file).

dependencies {
   testImplementation 'com.ncorti:rules4android:1.0.0'
}

or if you need it from your Espresso tests:

dependencies {
   androidTestImplementation 'com.ncorti:rules4android:1.0.0'
}

RetryRule

You can use a RetryRule to retry tests that might be flaky, just by annotating them with a @RetryOnFailure. By default, annotated tests are retried other 2 times. You can specify the retry count in the annotation. If the test fails more than 1 + retryCount times, a message will be printed out on the console.

Example:

class ExampleTest {

    @get:Rule val rule = RetryRule()

    @Test
    @RetryOnFailure(10) // 10 can be omitted, will default to 2.
    fun aFlakyTest() {
        assertEquals(2, Math.random().toInt())
    }
}

More examples can be found in the RetryRuleTest.kt file.

LoggingRule

You can use a LoggingRule to print out the execution time of every test. If you need more structured data for further processing of your tests, you can pass a flag to the Rule to enable the CSV output.

Example:

class ExampleTest {

    @get:Rule val rule = TimingRule(printCsv = false)

    @Test
    fun aLongTest() {
        Thread.sleep(1000)
        assertEquals(42, 42)
    }
}

Will print on the console:

ExampleTest:aLongTest took 1001 ms

More examples can be found in the LoggingRuleTest.kt file.

LocaleRule

You can use a LocaleRule to change locale of the device/JVM. The rule has support for both JUnit and Espresso tests. You can either pass a locale via the @ChangeLocale annotation, or via a parameter in the Rule constructor.

Example:

class ExampleTest {

    @get:Rule val rule = LocaleRule(Locale.ITALIAN)

    @Test
    fun anItalianTest() {
        // Locale Changed by constructor parameter.
        assertEquals("it", Locale.getDefault().language)
    }

    @Test
    @ChangeLocale("de")
    fun aGermanTest() {
        // Locale Changed by annotation.
        assertEquals("de", Locale.getDefault().language)
    }
}

More examples can be found in the LocaleRuleTest.kt file.

Contributing 🤝

Looking for contributors! Don't be shy. 😁 Feel free to open issues/pull requests to help me improve this project.

License 📄

This project is licensed under the MIT License - see the License file for details

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].