File: use-old-expect-test.patch

package info (click to toggle)
libtruth-java 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 268 kB
  • ctags: 324
  • sloc: java: 1,607; xml: 29; makefile: 23; sh: 1
file content (78 lines) | stat: -rw-r--r-- 2,617 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Description: Revert to using version of ExpectTest.java from 0.5 release
Author: Brian Thomason <brian.thomason@eucalyptus.com>
Origin: upstream, https://raw.github.com/truth0/truth/84aa56ea5e48713b2555a5931160d65f13e23fe2/src/test/java/org/junit/contrib/truth/ExpectTest.java

--- libtruth-java-0.7.0.orig/src/test/java/org/junit/contrib/truth/ExpectTest.java
+++ libtruth-java-0.7.0/src/test/java/org/junit/contrib/truth/ExpectTest.java
@@ -16,55 +16,33 @@
  */
 package org.junit.contrib.truth;
 
+import java.util.Arrays;
+
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.MethodRule;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
 
 /**
- * Tests (and effectively sample code) for the Expect verb (implemented as a
- * rule)
+ * Tests (and effectively sample code) for the Expect 
+ * verb (implemented as a rule)
  * 
  * @author David Saff
  * @author Christian Gruber (cgruber@israfil.net)
  */
 @RunWith(JUnit4.class)
 public class ExpectTest {
-	private Expect oopsNotARule = Expect.create();
-
-	private Expect EXPECT = Expect.create();
-	private ExpectedException thrown = ExpectedException.none();
-
-	@Rule public MethodRule wrapper = new MethodRule() {
-		@Override
-		public Statement apply(Statement base, FrameworkMethod method, Object target) {
-			Statement expected = EXPECT.apply(base, method, target);
-			return thrown.apply(expected, method, target);
-		}
-	};
-
-	@Test
-	public void expectTrue() {
-		EXPECT.that(4).isEqualTo(4);
-	}
-
-	@Test
-	public void expectFail() {
-		thrown.expectMessage("All failed expectations:");
-		thrown.expectMessage("1. Not true that <abc> contains <x>");
-		thrown.expectMessage("2. Not true that <abc> contains <y>");
-		thrown.expectMessage("3. Not true that <abc> contains <z>");
-		EXPECT.that("abc").contains("x").and().contains("y").and().contains("z");
-	}
+  @Rule public Expect EXPECT = Expect.create();
 
-	@Test
-	public void warnWhenExpectIsNotRule() {
-		String message = "assertion made on Expect instance, but it's not enabled as a @Rule.";
-		thrown.expectMessage(message);
-		oopsNotARule.that(true).is(true);
-	}
+  @Test public void expectTrue() {
+    EXPECT.that(4).isEqualTo(4);
+  }
+
+  @Ignore @Test public void expectFail() {
+    EXPECT.that("abc").contains("x")
+          .and().contains("y")
+          .and().contains("z");
+    EXPECT.that(Arrays.asList(new String[]{"a", "b", "c"})).containsAnyOf("a", "c");
+  }
 }