Shuji Watanabe avatar Shuji Watanabe committed 6cf7d95

10章のコードを追加

Comments (0)

Files changed (6)

junit-examples/ch10_list.txt

+第10章
+------------------
+リスト10.1   src/test/java/ch10/SlowTests.java
+リスト10.2   src/test/java/ch10/FastTests.java
+リスト10.3   src/test/java/ch10/FooTest.java
+リスト10.4   src/test/java/ch10/BarTest.java
+リスト10.5   src/test/java/ch10/CategorizedTest.java
+
+
+
+

junit-examples/src/test/java/ch10/BarTest.java

+package ch10;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * リスト10.4
+ * @author shuji.w6e
+ */
+@Category(FastTests.class)
+public class BarTest {
+
+    @Test
+    public void test01() throws Exception {
+        System.out.println("BarTest#test01");
+    }
+
+    @Test
+    public void test02() throws Exception {
+        System.out.println("BarTest#test02");
+    }
+}

junit-examples/src/test/java/ch10/CategorizedTest.java

+package ch10;
+
+import org.junit.experimental.categories.Categories;
+import org.junit.experimental.categories.Categories.ExcludeCategory;
+import org.junit.experimental.categories.Categories.IncludeCategory;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * リスト10.5
+ * @author shuji.w6e
+ */
+@RunWith(Categories.class)
+@IncludeCategory(FastTests.class)
+@ExcludeCategory(SlowTests.class)
+@SuiteClasses({ FooTest.class, BarTest.class })
+public class CategorizedTest {
+}

junit-examples/src/test/java/ch10/FastTests.java

+package ch10;
+
+/**
+ * リスト10.2
+ * @author shuji.w6e
+ */
+public interface FastTests {
+}

junit-examples/src/test/java/ch10/FooTest.java

+package ch10;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * リスト10.3
+ * @author shuji.w6e
+ */
+public class FooTest {
+
+    @Category(FastTests.class)
+    @Test
+    public void fastTest() throws Exception {
+        System.out.println("FooTest#fastTest");
+    }
+
+    @Category(SlowTests.class)
+    @Test
+    public void slowTest() throws Exception {
+        System.out.println("FooTest#slowTest");
+    }
+}

junit-examples/src/test/java/ch10/SlowTests.java

+package ch10;
+
+/**
+ * リスト10.1
+ * @author shuji.w6e
+ */
+public interface SlowTests {
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.