beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject [3/6] beam git commit: Added a test of default PAssert failure reason
Date Sat, 11 Mar 2017 15:06:37 GMT
Added a test of default PAssert failure reason


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/2485a4cc
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/2485a4cc
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/2485a4cc

Branch: refs/heads/master
Commit: 2485a4ccce18784abf520792ea36b7d3d6efc394
Parents: 0d08d2a
Author: Aviem Zur <aviemzur@gmail.com>
Authored: Wed Mar 1 08:10:03 2017 +0200
Committer: Aviem Zur <aviemzur@gmail.com>
Committed: Fri Mar 10 23:13:38 2017 +0200

----------------------------------------------------------------------
 .../apache/beam/sdk/testing/PAssertTest.java    | 21 ++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/2485a4cc/sdks/java/core/src/test/java/org/apache/beam/sdk/testing/PAssertTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/testing/PAssertTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/testing/PAssertTest.java
index f50adf4..9bdb1b5 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/testing/PAssertTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/testing/PAssertTest.java
@@ -393,8 +393,25 @@ public class PAssertTest implements Serializable {
 
     Throwable thrown = runExpectingAssertionFailure(pipeline);
 
-    assertThat(thrown.getMessage(), containsString("Vals should have been empty"));
-    assertThat(thrown.getMessage(), containsString("Expected: iterable over [] in any order"));
+    String message = thrown.getMessage();
+
+    assertThat(message, containsString("Vals should have been empty"));
+    assertThat(message, containsString("Expected: iterable over [] in any order"));
+  }
+
+  @Test
+  @Category(RunnableOnService.class)
+  public void testEmptyFalseDefaultReasonString() throws Exception {
+    PCollection<Long> vals = pipeline.apply(CountingInput.upTo(5L));
+    PAssert.that(vals).empty();
+
+    Throwable thrown = runExpectingAssertionFailure(pipeline);
+
+    String message = thrown.getMessage();
+
+    assertThat(message,
+        containsString("CountingInput.BoundedCountingInput/Read(BoundedCountingSource).out"));
+    assertThat(message, containsString("Expected: iterable over [] in any order"));
   }
 
   private static Throwable runExpectingAssertionFailure(Pipeline pipeline) {


Mime
View raw message