Skip to content

Commit

Permalink
Fix AssertionFailureIgnored ErrorProne issue
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 274856944
  • Loading branch information
donaldchai authored and copybara-github committed Oct 15, 2019
1 parent 896137a commit 602bb2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.fail;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand All @@ -28,6 +27,7 @@
import com.google.devtools.build.lib.rules.android.AndroidConfiguration.AndroidAaptVersion;
import com.google.devtools.build.lib.rules.android.databinding.DataBinding;
import com.google.devtools.build.lib.rules.android.databinding.DataBindingContext;
import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Optional;
import org.junit.Before;
Expand Down Expand Up @@ -507,28 +507,32 @@ public void test_incompatibleProhibitAapt1_targetsAapt2() throws Exception {
public void test_incompatibleProhibitAapt1_aaptVersionAapt_throwsAttributeError()
throws Exception {
useConfiguration("--incompatible_prohibit_aapt1");
try {
getRuleContext(
"android_binary", "aapt_version = 'aapt',", "manifest = 'AndroidManifest.xml',");
fail("Expected AssertionError");
} catch (AssertionError e) {
assertThat(e).hasMessageThat().contains("aapt_version");
assertThat(e).hasMessageThat().contains("Attribute is no longer supported");
}
AssertionError e =
MoreAsserts.assertThrows(
AssertionError.class,
() ->
getRuleContext(
"android_binary",
"aapt_version = 'aapt',",
"manifest = 'AndroidManifest.xml',"));
assertThat(e).hasMessageThat().contains("aapt_version");
assertThat(e).hasMessageThat().contains("Attribute is no longer supported");
}

@Test
public void test_incompatibleProhibitAapt1_aaptVersionAapt2_throwsAttributeError()
throws Exception {
useConfiguration("--incompatible_prohibit_aapt1");
try {
getRuleContext(
"android_binary", "aapt_version = 'aapt2',", "manifest = 'AndroidManifest.xml',");
fail("Expected AssertionError");
} catch (AssertionError e) {
assertThat(e).hasMessageThat().contains("aapt_version");
assertThat(e).hasMessageThat().contains("Attribute is no longer supported");
}
AssertionError e =
MoreAsserts.assertThrows(
AssertionError.class,
() ->
getRuleContext(
"android_binary",
"aapt_version = 'aapt2',",
"manifest = 'AndroidManifest.xml',"));
assertThat(e).hasMessageThat().contains("aapt_version");
assertThat(e).hasMessageThat().contains("Attribute is no longer supported");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ java_test(
"//src/main/java/com/google/devtools/build/lib/actions",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/test/java/com/google/devtools/build/lib:packages_testutil",
"//src/test/java/com/google/devtools/build/lib:testutil",
"//third_party:guava",
"//third_party:junit4",
"//third_party:truth",
Expand Down

0 comments on commit 602bb2e

Please sign in to comment.