aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ajmichael <ajmichael@google.com>2017-09-22 15:14:30 -0400
committerGravatar John Cater <jcater@google.com>2017-09-25 09:38:33 -0400
commita9573d8f751f73a0ff70133a1c440f7b99e245d0 (patch)
tree79b44bfa32ca4a499bc8661729dc2a07606ad075
parented4405d147f3f1216a60283896ece8ebd37424bb (diff)
Fix error-prone warning on AndroidBinaryTest.
The test was not incorrect before, however it was unfortunate that we were both expecting an AssertionError and also throwing an AssertionError to signal that no AssertionError was thrown. RELNOTES: None PiperOrigin-RevId: 169721076
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
index 22ec0170cc..d3528ccf9a 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
@@ -17,7 +17,7 @@ import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith;
-import static org.junit.Assert.fail;
+import static com.google.devtools.build.lib.testutil.MoreAsserts.expectThrows;
import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
@@ -106,12 +106,12 @@ public class AndroidBinaryTest extends AndroidBuildViewTestCase {
// --android_cpu with --android_crosstool_top also triggers the split transition.
useConfiguration("--fat_apk_cpu=doesnotexist",
"--android_crosstool_top=//android/crosstool:everything");
- try {
- getConfiguredTarget("//test/skylark:test");
- fail("Expected an error that no toolchain matched.");
- } catch (AssertionError e) {
- assertThat(e.getMessage()).contains("No toolchain found for cpu 'doesnotexist'");
- }
+
+ AssertionError noToolchainError =
+ expectThrows(AssertionError.class, () -> getConfiguredTarget("//test/skylark:test"));
+ assertThat(noToolchainError)
+ .hasMessageThat()
+ .contains("No toolchain found for cpu 'doesnotexist'");
}
@Test