A set of handy junit rules.
testImplementation 'com.vanniktech:junit4-rules:0.3.0'
testImplementation 'com.vanniktech:junit4-rules:0.4.0-SNAPSHOT'
JUnit rule for taking control over the Locale.
/** Creates the rule and will safely restore the default locale for each test. */
@Rule public final DefaultLocaleRule defaultLocaleRule = new DefaultLocaleRule();
/** Creates the rule and will set the preferred locale for each test. */
@Rule public final DefaultLocaleRule defaultLocaleRule = new DefaultLocaleRule(US);
JUnit rule for taking control over the Timezone.
/** Creates the rule and will safely restore the default timezone for each test. */
@Rule public final DefaultTimeZoneRule defaultTimeZoneRule = new DefaultTimeZoneRule();
/** 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.
androidTestImplementation 'com.vanniktech:junit4-android-integration-rules:0.2.0'
androidTestImplementation 'com.vanniktech:junit4-android-integration-rules:0.3.0-SNAPSHOT'
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 for this inspiration and sharing the initial piece.
/** 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();
/** 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.
Copyright (C) 2017 Vanniktech - Niklas Baudy
Licensed under the Apache License, Version 2.0