This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
| import java.util.Arrays; | |
| class NonCapturing { | |
| public static void main(String... args) { | |
| run(new Runnable() { | |
| @Override public void run() { | |
| System.out.println("Hey!"); | |
| } | |
| }); | |
| } | 
| #!/bin/bash | |
| if [ $# != 1 ]; then | |
| echo "Pass jar as sole argument" | |
| exit 1 | |
| fi | |
| tmp=`mktemp -d` | |
| unzip -d "$tmp" $1 1> /dev/null | 
| interface Thing<T> { | |
| T thing(); | |
| } | |
| class CharSequenceThing implements Thing<CharSequence> { | |
| @Override public CharSequence thing() { | |
| return "CharSequence!"; | |
| } | |
| } | 
| interface Thing { | |
| Object thing(); | |
| } | |
| class CharSequenceThing implements Thing { | |
| @Override public CharSequence thing() { | |
| return "CharSequence!"; | |
| } | |
| } | 
| /* | |
| * Copyright (C) 2015 Jake Wharton | |
| * | |
| * 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 | 
| import org.junit.rules.TestRule; | |
| import org.junit.runner.Description; | |
| import org.junit.runners.model.Statement; | |
| /** Got flaky tests? Shampoo them away. */ | |
| public final class ShampooRule implements TestRule { | |
| private final int iterations; | |
| public ShampooRule(int iterations) { | |
| if (iterations < 1) throw new IllegalArgumentException("iterations < 1: " + iterations); | 
| def installAll = tasks.create('installAll') | |
| installAll.description = 'Install all applications.' | |
| android.applicationVariants.all { variant -> | |
| installAll.dependsOn(variant.install) | |
| // Ensure we end up in the same group as the other install tasks. | |
| installAll.group = variant.install.group | |
| } | 
| /* | |
| * Copyright (C) 2015 Jake Wharton | |
| * | |
| * 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 | 
| /** | |
| * Show the activity over the lockscreen and wake up the device. If you launched the app manually | |
| * both of these conditions are already true. If you deployed from the IDE, however, this will | |
| * save you from hundreds of power button presses and pattern swiping per day! | |
| */ | |
| public static void riseAndShine(Activity activity) { | |
| activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED); | |
| PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE); | |
| PowerManager.WakeLock lock = | 
This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html