{"id":5046,"date":"2018-06-23T13:28:27","date_gmt":"2018-06-23T04:28:27","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=5046"},"modified":"2023-04-27T06:45:25","modified_gmt":"2023-04-26T21:45:25","slug":"%e3%80%90junit%e3%80%91%e4%bd%bf%e7%94%a8%e3%81%a7%e3%81%8d%e3%82%8b%e3%80%8c%e3%82%a2%e3%83%8e%e3%83%86%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%80%8d%e3%81%ae%e7%a8%ae%e9%a1%9e","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=5046","title":{"rendered":"\u3010JUnit\u3011JUnit\u306e\u57fa\u672c\u3084\u3001\u4f7f\u7528\u3067\u304d\u308b\u300c\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u300d\u306e\u7a2e\u985e"},"content":{"rendered":"<h2>JUnit\u306e\u6a5f\u80fd<\/h2>\n<ul>\n<li>\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af<\/li>\n<li>\u30c6\u30b9\u30c8\u306e\u671f\u5f85\u5024\u3068\u3001\u5b9f\u6e2c\u5024\u3092\u691c\u8a3c\u3057\u3066\u304f\u308c\u308b\u3002<\/li>\n<li>\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8<\/li>\n<\/ul>\n<h2>\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u30e1\u30ea\u30c3\u30c8<\/h2>\n<h3>\u4f55\u5ea6\u3082\u81ea\u52d5\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u70b9<\/h3>\n<p>\u30c6\u30b9\u30c8\u30ed\u30b8\u30c3\u30af\u3092JUnit\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u3057\u3066\u8a18\u8ff0\u3057\u3066\u304a\u304d\u3001\u4e00\u5ea6\u4f5c\u3063\u305f\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3092\u4f55\u5ea6\u3082\u7c21\u5358\u306b\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u307e\u3067\u30c7\u30b0\u30ec\u304c\u8d77\u304d\u308b\u3053\u3068\u3092\u6050\u308c\u3066\u3001\u6a5f\u80fd\u306e\u8ffd\u52a0\u3001\u6539\u4fee\u3092\u8e8a\u8e87\u308f\u308c\u3066\u3044\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3082\u591a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001JUnit\u3067\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308c\u3070\u3001<span style=\"color: #ff0000;\"><strong>\u4f55\u5ea6\u3082\u7c21\u5358\u306b\u30c6\u30b9\u30c8\u3092\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308b\u306e\u3067\u3001\u305d\u3046\u3057\u305f\u30c6\u30b9\u30c8\u306e\u624b\u9593\u304c\u5927\u5e45\u306b\u306a\u304f\u306a\u308a\u3001\u5b89\u5fc3\u3057\u3066\u6a5f\u80fd\u306e\u6539\u4fee\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/strong><\/span><\/p>\n<h3>\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u3001\u691c\u8a3c\u3001\u30c6\u30b9\u30c8\u7d50\u679c\u306e\u30ec\u30dd\u30fc\u30c8\u3092\u51fa\u529b\u3057\u3066\u304f\u308c\u308b\u70b9<\/h3>\n<p>\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u5b9f\u88c5\u3084\u3001\u30c6\u30b9\u30c8\u7d50\u679c\u306e\u78ba\u8a8d\u3060\u3051\u3067\u3042\u308c\u3070\u3001JUnit\u3092\u4f7f\u308f\u305a\u306b\u81ea\u5206\u3067Java\u3067\u5b9f\u88c5\u3059\u308b\u3053\u3068\u306f\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001JUnit\u7b49\u306e\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u306f\u3001\u691c\u8a3c\u3084\u3001\u30c6\u30b9\u30c8\u7d50\u679c\u306e\u30ec\u30dd\u30fc\u30c8\u3092\u51fa\u529b\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3001<span style=\"color: #ff0000;\"><strong>\u3044\u3061\u3044\u3061\u81ea\u5206\u3067\u305d\u308c\u3089\u3092\u5b9f\u88c5\u3059\u308b\u624b\u9593\u304c\u7701\u3051\u3066\u3001\u30c6\u30b9\u30c8\u306e\u8a2d\u8a08\u3068\u3001\u5b9f\u88c5\u306b\u5c02\u5ff5\u304c\u3067\u304d\u307e\u3059\u3002<\/strong><\/span><\/p>\n<h2>JUnit\u306e\u30e9\u30a4\u30bb\u30f3\u30b9<\/h2>\n<p>CPL(Common Public License)\u30e9\u30a4\u30bb\u30f3\u30b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>JUnit4\u306e\u7279\u5fb4<\/h2>\n<p>JUnit\u306e\u6700\u65b0\u30e1\u30b8\u30e3\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300c4\u300d<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>3\u304b\u30894\u3078\u306e\u5927\u304d\u306a\u5909\u66f4\u70b9\u3068\u3057\u3066\u306f\u3001Java5\u304b\u3089\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b<span style=\"color: #ff0000;\"><strong>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9<\/strong><\/span>\u306b\u306a\u3063\u305f\u3053\u3068\u3067\u3059\u3002<\/p>\n<h2>JUnit4\u306e\u30d0\u30fc\u30b8\u30e7\u30f3<\/h2>\n<table>\n<tbody>\n<tr>\n<th>\u30d0\u30fc\u30b8\u30e7\u30f3<\/th>\n<th>\u30ea\u30ea\u30fc\u30b9\u65e5<\/th>\n<th>\u7279\u5fb4<\/th>\n<\/tr>\n<tr>\n<td>4.9<\/td>\n<td>2012\u5e7410\u670821\u65e5<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>4.10<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>4.11<\/td>\n<td>2014\u5e742\u670821\u65e5<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>4.12<\/td>\n<td>2014\u5e7412\u67084\u65e5<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>4.13<\/td>\n<td>2016\u5e743\u67086\u65e5<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u30c6\u30b9\u30c8\u30af\u30e9\u30b9<\/h2>\n<p>\u30c6\u30b9\u30c8\u3092\u81ea\u52d5\u5316\u3059\u308b\u305f\u3081\u306e\u30af\u30e9\u30b9\u3067\u3059\u3002\u3053\u306e\u4e2d\u306b\u30c6\u30b9\u30c8\u30eb\u30fc\u30eb\u3092\u8a18\u8f09\u3059\u308b<span style=\"color: #ff0000;\"><strong>\u300c\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u300d<\/strong><\/span>\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u306e\u8a18\u8ff0\u30eb\u30fc\u30eb<\/h3>\n<p>public\u30af\u30e9\u30b9\u3068\u3059\u308b\u3002<\/p>\n<h2>\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9<\/h2>\n<p>JUnit\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u30eb\u30fc\u30eb\u306b\u5f93\u3063\u305f\u30e1\u30bd\u30c3\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>1\u30e1\u30bd\u30c3\u30c9\u304c\u30011\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9<\/strong><\/span>\u306b\u306a\u308a\u3001<span style=\"color: #ff0000;\"><strong>1\u3064\u306e\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u306b\u8907\u6570\u306e\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<h3>\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u306e\u8a18\u8ff0\u30eb\u30fc\u30eb<\/h3>\n<ul>\n<li>org.junit.Test\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\uff08@Test\uff09\u3092\u4ed8\u4e0e\u3059\u308b\u3002<\/li>\n<li>public\u30e1\u30bd\u30c3\u30c9\u3068\u3059\u308b\u3002<\/li>\n<li>\u5f15\u6570\u306f\u6301\u305f\u306a\u3044\u3002<\/li>\n<li>\u623b\u308a\u5024\u306fvoid<\/li>\n<li>throws\u306f\u81ea\u7531\u306b\u5b9a\u7fa9\u304c\u53ef\u80fd\u3067\u3059\u3002<\/li>\n<\/ul>\n<h3>\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u3092\u8a18\u8ff0\u3059\u308b\u969b\u306e\u63a8\u5968\u30eb\u30fc\u30eb<\/h3>\n<p>\u57fa\u672c\u7684\u306b\u3001Java\u30b3\u30fc\u30c9\u306e\u30e1\u30bd\u30c3\u30c9\u540d\u3092\u8a18\u8f09\u3059\u308b\u5834\u5408\u306f\u3001\u82f1\u8a9e\u540d\u3092\u8a18\u8f09\u3057\u3066\u3044\u304f\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u306e\u30e1\u30bd\u30c3\u30c9\u540d\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u65e5\u672c\u8a9e\u540d<\/strong><\/span>\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u308f\u304b\u308a\u3084\u3059\u3044\u306e\u3067\u63a8\u5968\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>throws\u53e5\u306b\u3064\u3044\u3066<\/h3>\n<p>\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u304c\u4f8b\u5916\u3092\u51fa\u3057\u305f\u969b\u306b\u3001\u30c6\u30b9\u30c8\u3092\u5931\u6557\u3068\u3057\u3066\u6271\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u306b\u3001throws\u53e5\u306b\u306f\u901a\u5e38\u306f\u3001<span style=\"color: #ff0000;\"><strong>Exception\u30af\u30e9\u30b9<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h4>Exception\u30af\u30e9\u30b9\u306b\u3059\u308b\u7406\u7531<\/h4>\n<p>\u901a\u5e38\u306e\u958b\u767a\u3067\u306f\u3001Exception\u3092throws\u306b\u3059\u308b\u306e\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300c\u4f55\u306e\u4f8b\u5916\u3067\u3042\u308b\u304b\u308f\u3089\u304b\u306a\u3044\u300d<\/strong><\/span>\u305f\u3081\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u7b49\u3067\u3001\u7981\u6b62\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u305f\u3060\u3001JUnit\u3067\u306f\u3001\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u5185\u306b\u69d8\u3005\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u8a18\u8ff0\u3057\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30e1\u30bd\u30c3\u30c9\u306b\u3088\u3063\u3066\u69d8\u3005\u306a\u4f8b\u5916\u304c\u751f\u307f\u51fa\u3055\u308c\u305d\u306e\u305f\u3073\u306b\u3001throws\u53e5\u3092\u4fee\u6b63\u3059\u308b\u306e\u306f\u975e\u5e38\u306b\u5927\u5909\u306a\u306e\u3067\u3001\u4e00\u5f8b<span style=\"color: #ff0000;\"><strong>\u300cException\u30af\u30e9\u30b9\u300d<\/strong><\/span>\u3092\u4f7f\u3046\u306e\u3067\u3059\u3002<\/p>\n<h2>\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u3067\u306e\u691c\u8a3c\uff08\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\uff09<\/h2>\n<p>JUnit\u3067\u3001\u30c6\u30b9\u30c8\u7d50\u679c\u3092\u691c\u8a3c\u3059\u308b\u306b\u306f\u3001\u4e3b\u306b<span style=\"color: #ff0000;\"><strong>org.junit.Assert\u30af\u30e9\u30b9\u306eassertThat\u30e1\u30bd\u30c3\u30c9<\/strong><\/span>\u3068\u3001<span style=\"color: #ff0000;\"><strong>Matcher API<\/strong><\/span>\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<h3>\u69cb\u6587<\/h3>\n<pre class=\"lang:default decode:true\">assertThat(\u5b9f\u6e2c\u5024, \u671f\u5f85\u5024\u3092\u542b\u3080Matcher\u30aa\u30d6\u30b8\u30a7\u30af\u30c8);<\/pre>\n<h3>\u4f8b<\/h3>\n<pre class=\"lang:default decode:true\">import static org.hamcrest.CoreMatchers.*;\r\nimport static org.junit.Assert.*;\r\nimport org.junit.Test;\r\n\r\npublic class Test {\r\n\u3000\u3000@Test\r\n\u3000\u3000public void test() {\r\n   \u3000\u3000 \u30c6\u30b9\u30c8\u5bfe\u8c61\u30af\u30e9\u30b9 \u30c6\u30b9\u30c8\u5bfe\u8c61\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 = new \u30c6\u30b9\u30c8\u5bfe\u8c61\u30af\u30e9\u30b9();\r\n    \u3000\u3000int \u671f\u5f85\u5024 = \u671f\u5f85\u5024;\r\n    \u3000\u3000int \u5b9f\u6e2c\u5024 = \u30c6\u30b9\u30c8\u5bfe\u8c61\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8.\u30c6\u30b9\u30c8\u5bfe\u8c61\u306e\u30e1\u30bd\u30c3\u30c9(\u5f15\u6570);\r\n    \u3000\u3000assertThat(\u5b9f\u6e2c\u5024, is(\u671f\u5f85\u5024));\r\n\u3000\u3000}\r\n}\r\n<\/pre>\n<h4>is\u30e1\u30bd\u30c3\u30c9<\/h4>\n<p>org.hamcrest.CoreMatchers.Matcher\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3059\u308b<span style=\"color: #ff0000;\"><strong>\u30d5\u30a1\u30af\u30c8\u30ea\u30e1\u30bd\u30c3\u30c9<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<p>static\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u4f7f\u3046\u306e\u3067\u3001\u30af\u30e9\u30b9\u540d\u3092\u7701\u7565\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u4f7f\u7528\u3067\u304d\u308b\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e<\/h2>\n<p>\u300c\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u300d\u306b\u3066\u3001\u4f7f\u7528\u3067\u304d\u308b\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3068\u3057\u3066\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300c@Test\u300d<\/strong><\/span>\u4ee5\u5916\u306b\u3082\u591a\u304f\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>JUnit\u3067\u306f\u3001\u4e0b\u8a18\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>@Test<\/li>\n<li>@Ignore<\/li>\n<li>@Before<\/li>\n<li>@After<\/li>\n<li>@BeforeClass<\/li>\n<li>@AfterClass<\/li>\n<\/ul>\n<h3>@Test<\/h3>\n<p>\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\uff08\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\uff09\u3092\u5ba3\u8a00\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u5f15\u6570\u3068\u3057\u3066\u306f\u4e0b\u8a18\u306e\u4e8c\u3064\u3092\u6301\u3061\u307e\u3059\u3002<\/p>\n<ul>\n<li>expected\u5c5e\u6027<\/li>\n<li>timeout\u5c5e\u6027<\/li>\n<\/ul>\n<h4>expected\u5c5e\u6027<\/h4>\n<p>\u4f8b\u5916\u306e\u9001\u51fa\u3092\u691c\u8a3c\u3059\u308b\u30c6\u30b9\u30c8\u3067\u3001\u9001\u51fa\u304c\u671f\u5f85\u3055\u308c\u308b\u4f8b\u5916\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u30c6\u30b9\u30c8\u5bfe\u8c61\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3001<span style=\"color: #ff0000;\"><strong>\u300cIOException\u300d<\/strong><\/span>\u306e\u767a\u751f\u3092\u671f\u5f85\u3059\u308b\u306e\u3067\u3042\u308c\u3070\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">@Test(expected = IOException.class)<\/pre>\n<h4>timeout\u5c5e\u6027<\/h4>\n<p>\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u306e\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u5024\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u306b\u5bfe\u3057\u3066\u3001<span style=\"color: #ff0000;\"><strong>\u3053\u3053\u3067\u6307\u5b9a\u3057\u305f\u6642\u9593\u4ee5\u4e0a\u306b\u6642\u9593\u304c\u304b\u304b\u3063\u305f\u5834\u5408\u306f\u3001\u30c6\u30b9\u30c8\u304c\u5931\u6557<\/strong><\/span>\u3068\u307f\u306a\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001timeout\u5c5e\u6027\u3092\u6307\u5b9a\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u3001\u6c38\u9060\u306b\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u306f\u7d42\u4e86\u3057\u307e\u305b\u3093\u3002<\/p>\n<h3>@Ignore<\/h3>\n<p>\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u304b\u3089\u9664\u5916\u3059\u308b\u305f\u3081\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<p>\u4e00\u6642\u7684\u306b\u306a\u3093\u3089\u304b\u306e\u7406\u7531\u3067\u3001\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3092\u5b9f\u884c\u3057\u305f\u304f\u306a\u3044\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<h3>@Before<\/h3>\n<p>\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u524d\u306b\u51e6\u7406\u3092\u884c\u308f\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u5168\u3066\u306e\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u3067\u5171\u901a\u3059\u308b\u521d\u671f\u5316\u51e6\u7406<\/strong><\/span>\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<p>\u6163\u4f8b\u3068\u3057\u3066\u3001\u30e1\u30bd\u30c3\u30c9\u306e\u540d\u524d\u306f<span style=\"color: #ff0000;\"><strong>\u300csetUp\u300d<\/strong><\/span>\u3068\u3044\u3046\u540d\u524d\u306b\u3057\u307e\u3059\u3002<\/p>\n<h4>\u5171\u901a\u5316\u5bfe\u8c61<\/h4>\n<p>\u51e6\u7406\u306e\u5171\u901a\u5316\u5bfe\u8c61\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u540c\u4e00\u306e\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u5185<\/strong><\/span>\u306b\u3068\u3069\u3081\u307e\u3057\u3087\u3046\u3002\u7d99\u627f\u3092\u4f7f\u7528\u3059\u308c\u3070\u3001\u8907\u6570\u306e\u30af\u30e9\u30b9\u306b\u5171\u901a\u3057\u305f\u5171\u901a\u51e6\u7406\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3082\u51fa\u6765\u306a\u304f\u306a\u3044\u3067\u3059\u304c\u3001\u907f\u3051\u305f\u65b9\u304c\u7121\u96e3\u3067\u3059\u3002<\/p>\n<h3>@After<\/h3>\n<p>\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u5f8c\u7d9a\u51e6\u7406\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\u30e1\u30bd\u30c3\u30c9\u540d\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300ctearDown\u300d<\/strong><\/span>\u3068\u3044\u3046\u540d\u524d\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u7d42\u4e86\u51e6\u7406\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30c6\u30b9\u30c8\u306e\u6210\u5426\u306b\u9650\u3089\u305a\u3001\u5fc5\u305a\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/strong><\/span><\/p>\n<h4>\u7528\u9014<\/h4>\n<p>\u300c\u30ea\u30bd\u30fc\u30b9\u306e\u89e3\u653e\u300d\u7b49\u306e\u30e1\u30bd\u30c3\u30c9\u7d42\u4e86\u6642\u306b\u884c\u308f\u305b\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u51e6\u7406\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<h3>@BeforeClass<\/h3>\n<p>@Before\u3068\u540c\u3058\u3088\u3046\u306b\u3001\u30c6\u30b9\u30c8\u5b9f\u884c\u524d\u306b\u4e00\u5ea6\u3060\u3051\u51e6\u7406\u3092\u884c\u308f\u305b\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001Before\u3068\u7570\u306a\u308a\u3001<span style=\"color: #ff0000;\"><strong>\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u5358\u4f4d\u30671\u56de\u3060\u3051\u5b9f\u884c<\/strong><\/span>\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u9593\u306f\u72ec\u7acb\u3057\u3066\u3044\u308b\u3079\u304d\u3068\u3044\u3046\u3001\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u306e\u57fa\u672c\u65b9\u91dd\u304c\u3042\u308b\u306e\u3067\u3001<span style=\"color: #ff0000;\"><strong>\u57fa\u672c\u7684\u306b\u3053\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u3053\u3068\u306f\u3042\u307e\u308a\u3042\u308a\u307e\u305b\u3093\u3002<\/strong><\/span><\/p>\n<h3>@AfterClass<\/h3>\n<p>@After\u3068\u540c\u3058\u3088\u3046\u306b\u3001\u30c6\u30b9\u30c8\u5b9f\u884c\u5f8c\u306b\u4e00\u5ea6\u3060\u3051\u51e6\u7406\u3092\u884c\u308f\u305b\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001After\u3068\u7570\u306a\u308a\u3001<span style=\"color: #ff0000;\"><strong>\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u5358\u4f4d\u30671\u56de\u3060\u3051\u5b9f\u884c<\/strong><\/span>\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u300c@BeforeClass\u300d\u3068\u540c\u3058\u3088\u3046\u306b\u3001\u57fa\u672c\u7684\u306b\u3053\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u6a5f\u4f1a\u306f\u5c11\u306a\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"JUnit\u306e\u6a5f\u80fd \u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af \u30c6\u30b9\u30c8\u306e\u671f\u5f85\u5024\u3068\u3001\u5b9f\u6e2c\u5024\u3092\u691c\u8a3c\u3057\u3066\u304f\u308c\u308b\u3002 \u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 \u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u30e1\u30ea\u30c3\u30c8 \u4f55\u5ea6\u3082\u81ea\u52d5\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u70b9 \u30c6\u30b9\u30c8\u30ed\u30b8\u30c3\u30af\u3092JUnit\u306e\u30d7 [&hellip;]","protected":false},"author":1,"featured_media":4985,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5046"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5046"}],"version-history":[{"count":7,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5046\/revisions"}],"predecessor-version":[{"id":19238,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5046\/revisions\/19238"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/4985"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5046"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}