aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/testutil
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2017-05-30 12:35:33 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-05-30 12:51:57 +0200
commitaea56b36af994b269800602e36000c293cabd00b (patch)
tree794f6b3b2528353cc39bd383730d408d4ff25233 /src/test/java/com/google/devtools/build/lib/testutil
parent229f393bf460700594ae032a551879e026bd0b91 (diff)
Migrate Java tests to Truth.
RELNOTES: None. PiperOrigin-RevId: 157446717
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/testutil')
-rw-r--r--src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/testutil/MoreAssertsTest.java15
-rw-r--r--src/test/java/com/google/devtools/build/lib/testutil/TestSizeAnnotationTest.java30
3 files changed, 23 insertions, 28 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java b/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
index 5a1f89e6d3..576c2f38ae 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
@@ -16,7 +16,6 @@ package com.google.devtools.build.lib.testutil;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assert_;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.base.Function;
@@ -185,8 +184,9 @@ public class MoreAsserts {
public static void assertContainsWordsWithQuotes(String message,
String... strings) {
for (String string : strings) {
- assertTrue(message + " should contain '" + string + "' (with quotes)",
- message.contains("'" + string + "'"));
+ assertWithMessage(message + " should contain '" + string + "' (with quotes)")
+ .that(message.contains("'" + string + "'"))
+ .isTrue();
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/MoreAssertsTest.java b/src/test/java/com/google/devtools/build/lib/testutil/MoreAssertsTest.java
index 975e365361..372ede2284 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/MoreAssertsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/MoreAssertsTest.java
@@ -18,16 +18,13 @@ import static com.google.devtools.build.lib.testutil.MoreAsserts.assertContainsS
import static com.google.devtools.build.lib.testutil.MoreAsserts.assertDoesNotContainSublist;
import static org.junit.Assert.fail;
+import java.util.Arrays;
+import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Tests {@link com.google.devtools.build.lib.testutil.MoreAsserts}.
- */
+/** Tests {@link com.google.devtools.build.lib.testutil.MoreAsserts}. */
@RunWith(JUnit4.class)
public class MoreAssertsTest {
@@ -56,21 +53,21 @@ public class MoreAssertsTest {
assertContainsSublist(actual, "d");
fail("no exception thrown");
} catch (AssertionError e) {
- assertThat(e.getMessage()).startsWith("Did not find [d] as a sublist of [a, b, c]");
+ assertThat(e).hasMessageThat().startsWith("Did not find [d] as a sublist of [a, b, c]");
}
try {
assertContainsSublist(actual, "a", "c");
fail("no exception thrown");
} catch (AssertionError e) {
- assertThat(e.getMessage()).startsWith("Did not find [a, c] as a sublist of [a, b, c]");
+ assertThat(e).hasMessageThat().startsWith("Did not find [a, c] as a sublist of [a, b, c]");
}
try {
assertContainsSublist(actual, "b", "c", "d");
fail("no exception thrown");
} catch (AssertionError e) {
- assertThat(e.getMessage()).startsWith("Did not find [b, c, d] as a sublist of [a, b, c]");
+ assertThat(e).hasMessageThat().startsWith("Did not find [b, c, d] as a sublist of [a, b, c]");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/TestSizeAnnotationTest.java b/src/test/java/com/google/devtools/build/lib/testutil/TestSizeAnnotationTest.java
index 810cfa1cf7..4e02fa7ee3 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/TestSizeAnnotationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/TestSizeAnnotationTest.java
@@ -13,10 +13,8 @@
// limitations under the License.
package com.google.devtools.build.lib.testutil;
+import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.lib.testutil.Suite.getSize;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -81,58 +79,58 @@ public class TestSizeAnnotationTest {
@Test
public void testHasNoTestSpecAnnotationIsSmall() {
- assertEquals(Suite.SMALL_TESTS, getSize(HasNoTestSpecAnnotation.class));
+ assertThat(getSize(HasNoTestSpecAnnotation.class)).isEqualTo(Suite.SMALL_TESTS);
}
@Test
public void testHasNoSizeAnnotationElementIsSmall() {
- assertEquals(Suite.SMALL_TESTS, getSize(HasNoSizeAnnotationElement.class));
+ assertThat(getSize(HasNoSizeAnnotationElement.class)).isEqualTo(Suite.SMALL_TESTS);
}
@Test
public void testIsAnnotatedWithSmallSizeIsSmall() {
- assertEquals(Suite.SMALL_TESTS, getSize(IsAnnotatedWithSmallSize.class));
+ assertThat(getSize(IsAnnotatedWithSmallSize.class)).isEqualTo(Suite.SMALL_TESTS);
}
@Test
public void testIsAnnotatedWithMediumSizeIsMedium() {
- assertEquals(Suite.MEDIUM_TESTS, getSize(IsAnnotatedWithMediumSize.class));
+ assertThat(getSize(IsAnnotatedWithMediumSize.class)).isEqualTo(Suite.MEDIUM_TESTS);
}
@Test
public void testIsAnnotatedWithLargeSizeIsLarge() {
- assertEquals(Suite.LARGE_TESTS, getSize(IsAnnotatedWithLargeSize.class));
+ assertThat(getSize(IsAnnotatedWithLargeSize.class)).isEqualTo(Suite.LARGE_TESTS);
}
@Test
public void testSuperclassHasAnnotationButNoSizeElement() {
- assertEquals(Suite.SMALL_TESTS, getSize(SuperclassHasAnnotationButNoSizeElement.class));
+ assertThat(getSize(SuperclassHasAnnotationButNoSizeElement.class)).isEqualTo(Suite.SMALL_TESTS);
}
@Test
public void testHasSizeElementAndSuperclassHasAnnotationButNoSizeElement() {
- assertEquals(Suite.LARGE_TESTS,
- getSize(HasSizeElementAndSuperclassHasAnnotationButNoSizeElement.class));
+ assertThat(getSize(HasSizeElementAndSuperclassHasAnnotationButNoSizeElement.class))
+ .isEqualTo(Suite.LARGE_TESTS);
}
@Test
public void testSuperclassHasAnnotationWithSizeElement() {
- assertEquals(Suite.SMALL_TESTS, getSize(SuperclassHasAnnotationWithSizeElement.class));
+ assertThat(getSize(SuperclassHasAnnotationWithSizeElement.class)).isEqualTo(Suite.SMALL_TESTS);
}
@Test
public void testHasSizeElementAndSuperclassHasAnnotationWithSizeElement() {
- assertEquals(Suite.LARGE_TESTS,
- getSize(HasSizeElementAndSuperclassHasAnnotationWithSizeElement.class));
+ assertThat(getSize(HasSizeElementAndSuperclassHasAnnotationWithSizeElement.class))
+ .isEqualTo(Suite.LARGE_TESTS);
}
@Test
public void testIsNotFlaky() {
- assertFalse(Suite.isFlaky(HasNoTestSpecAnnotation.class));
+ assertThat(Suite.isFlaky(HasNoTestSpecAnnotation.class)).isFalse();
}
@Test
public void testIsFlaky() {
- assertTrue(Suite.isFlaky(FlakyTestSpecAnnotation.class));
+ assertThat(Suite.isFlaky(FlakyTestSpecAnnotation.class)).isTrue();
}
}