Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vanniktech/junit-rules
A set of handy junit rules.
https://github.com/vanniktech/junit-rules
junit junit-rule junit4 testing
Last synced: 6 days ago
JSON representation
A set of handy junit rules.
- Host: GitHub
- URL: https://github.com/vanniktech/junit-rules
- Owner: vanniktech
- License: apache-2.0
- Created: 2017-08-06T21:42:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-31T22:21:50.000Z (8 days ago)
- Last Synced: 2024-10-31T23:20:22.554Z (8 days ago)
- Topics: junit, junit-rule, junit4, testing
- Language: Kotlin
- Homepage: http://vanniktech.com
- Size: 625 KB
- Stars: 15
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/funding.yml
- License: LICENSE
Awesome Lists containing this project
README
junit-rules
===========A set of handy junit rules.
## JUnit 4
```groovy
testImplementation 'com.vanniktech:junit4-rules:0.3.0'
testImplementation 'com.vanniktech:junit4-rules:0.4.0-SNAPSHOT'
```### DefaultLocaleRule
JUnit rule for taking control over the Locale.
```java
/** Creates the rule and will safely restore the default locale for each test. */
@Rule public final DefaultLocaleRule defaultLocaleRule = new DefaultLocaleRule();
``````java
/** Creates the rule and will set the preferred locale for each test. */
@Rule public final DefaultLocaleRule defaultLocaleRule = new DefaultLocaleRule(US);
```### DefaultTimeZoneRule
JUnit rule for taking control over the Timezone.
```java
/** Creates the rule and will safely restore the default timezone for each test. */
@Rule public final DefaultTimeZoneRule defaultTimeZoneRule = new DefaultTimeZoneRule();
``````java
/** Creates the rule and will set the preferred timezone for each test. */
@Rule public final DefaultTimeZoneRule defaultTimeZoneRule = new DefaultTimeZoneRule(TimeZone.getTimeZone("GMT-08:00"));
```For more information have a look at the [tests](junit4-rules/src/test/java/com/vanniktech/junit4rules/).
## JUnit 4 Android Integration
```groovy
androidTestImplementation 'com.vanniktech:junit4-android-integration-rules:0.2.0'
androidTestImplementation 'com.vanniktech:junit4-android-integration-rules:0.3.0-SNAPSHOT'
```### DemoModeRule
JUnit rule for specifying some of the UI demo commands and customize some part of the Status as well as the Navigation bar. Thanks to [Hugo Visser](https://gist.github.com/hvisser/e716105f4e3cf2908ea463dbdb50679c) for this inspiration and sharing the initial piece.
```java
/** Creates the rule in default mode and shows you a clean status bar with half mobile data reception, 100% battery and an 11am clock. */
@Rule public final DemoModeRule demoModeRule = new DemoModeRule();
``````java
/** Creates the rule and lets you specify all of your preferred certain options. Have a look at the documentation for more information. */
@Rule public final DemoModeRule demoModeRule = new DemoModeRule(
notifications().visible(false),
network().wifi(true).mobileDataType(MOBILE_DATA_TYPE_E),
battery().level(11).plugged(false).powersave(true),
status().bluetooth(BLUETOOTH_MODE_CONNECTED).speakerphone(true),
clock().hhmm("1800")
)
```For more information have a look at the [tests](junit4-android-integration-rules/src/androidTest/java/com/vanniktech/junit4androidintegrationrules/).
# License
Copyright (C) 2017 Vanniktech - Niklas Baudy
Licensed under the Apache License, Version 2.0