{"id":433,"date":"2012-09-15T21:36:13","date_gmt":"2012-09-15T12:36:13","guid":{"rendered":"http:\/\/appsweets.net\/blog\/?p=433"},"modified":"2012-09-15T21:36:13","modified_gmt":"2012-09-15T12:36:13","slug":"watch-a-test","status":"publish","type":"post","link":"https:\/\/appsweets.net\/blog\/2012\/09\/15\/watch-a-test\/","title":{"rendered":"watch a test"},"content":{"rendered":"<div class=\"db9cc8cdb64025d13c1cc9dad0a0e262\" data-index=\"1\" style=\"float: left; margin: 16px 16px 16px 0;\">\n<script type=\"text\/javascript\"><!--\r\ngoogle_ad_client = \"ca-pub-5825700137064158\";\r\n\/* 250sq, appsweets-blog *\/\r\ngoogle_ad_slot = \"4837931762\";\r\ngoogle_ad_width = 250;\r\ngoogle_ad_height = 250;\r\n\/\/-->\r\n<\/script>\r\n<script type=\"text\/javascript\"\r\nsrc=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\r\n<\/script>\n<\/div>\n<p>\u30b0\u30b0\u308c\u3070\u305f\u304f\u3055\u3093\u60c5\u5831\u306f\u5f97\u3089\u308c\u308b\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u30e1\u30e2\u3002<\/p>\n<p>junit \u3067\u30c6\u30b9\u30c8\u3092\u66f8\u304f\u969b\u3001\u4eca\u4f55\u306e\u30c6\u30b9\u30c8\u3092\u3057\u3066\u3044\u308b\u306e\u304b\u2026\u2026\u306a\u3069\u306e\u30ed\u30b0\u3092\u5410\u304d\u305f\u3044\u3053\u3068\u304c\u3042\u308b\u3002\u4f8b\u3048\u3070 wasavi \u306e\u30c6\u30b9\u30c8\u3067\u3001\u4f55\u3089\u304b\u306e\u30df\u30b9\u304c\u3042\u3063\u3066\u3001WebDriverWait \u304c\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3059\u308b\u3068\u3059\u308b\u3002\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u81ea\u4f53\u306f catch \u7bc0\u3067\u53d7\u3051\u53d6\u308b\u306e\u3067\u3001\u305d\u3053\u3067\u5358\u306b System.out.println(&#8220;timed out!&#8221;); \u3059\u308c\u3070 ant \u304c\u4fdd\u5b58\u3059\u308b\u30ed\u30b0\u306b\u542b\u307e\u308c\u308b\u3002\u304c\u3001\u3069\u306e\u30c6\u30b9\u30c8\u3067\u767a\u751f\u3057\u305f\u304b\u307e\u3067\u306f\u308f\u304b\u3089\u306a\u3044\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3067<br \/>\n<code lang=\"java\"><br \/>\n@Test public void foo () {<br \/>\n\tSystem.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());<br \/>\n}<br \/>\n<\/code><br \/>\n\u306a\u3069\u3068\u66f8\u3051\u3070\u30ed\u30b0\u306b\u30c6\u30b9\u30c8\u4e2d\u306e\u30e1\u30bd\u30c3\u30c9\u540d\u304c\u66f8\u304b\u308c\u308b\u306e\u3067\u5224\u5225\u3059\u308b\u6750\u6599\u306b\u306a\u308b\u3002\u3057\u304b\u3057\u3053\u308c\u306f\u3059\u3079\u3066\u306e\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306b\u57cb\u3081\u8fbc\u307e\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u306e\u3067\u3001\u3068\u3066\u3082\u7169\u96d1\u3060\u3002<\/p>\n<p>\u3055\u3066 junit4 \u306b\u306f TestWatcher \u3068\u3044\u3046\u3082\u306e\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u3066\u3001\u30c6\u30b9\u30c8\u958b\u59cb\u30fb\u7d42\u4e86\u3001\u3042\u308b\u3044\u306f\u6210\u529f\u6642\u30fb\u5931\u6557\u6642\u306b\u4efb\u610f\u306e\u51e6\u7406\u3092\u306f\u3055\u3080\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u958b\u59cb\u30fb\u7d42\u4e86\u3068\u3044\u3046\u306e\u306f @Before \u3068 @After \u3068\u88ab\u3063\u3066\u3044\u308b\u304c\u3001\u3053\u308c\u3089\u306f\u3042\u304f\u307e\u3067\u30c6\u30b9\u30c8\u8996\u70b9\u3067\u306e\u958b\u59cb\u30fb\u7d42\u4e86\u306a\u306e\u306b\u5bfe\u3057\u3066\u3001TestWatcher \u306e\u305d\u308c\u306f\u30c6\u30b9\u30c8\u30e9\u30f3\u30ca\u30fc\u304b\u3089\u898b\u305f\u3001\u300c\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u300d\u306e\u958b\u59cb\u30fb\u7d42\u4e86\u3067\u3042\u308a\u3001\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u306e\u7d20\u6027\u306a\u3069\u306e\u30e1\u30bf\u306a\u60c5\u5831\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002 <\/p>\n<p><code lang=\"java\"><br \/>\nimport org.junit.*;<br \/>\nimport org.junit.rules.TestRule;<br \/>\nimport org.junit.rules.TestWatcher;<br \/>\nimport org.junit.runner.Description;<\/p>\n<p>public class WasaviTest {<br \/>\n\tprotected String logText;<\/p>\n<p>\t@Rule public TestRule watcher = new TestWatcher() {<br \/>\n\t\tprotected void starting (Description d) {<br \/>\n\t\t\tSystem.out.println(\"Testcase: \" + d.getMethodName());<br \/>\n\t\t}<br \/>\n\t\tprotected void failed (Throwable e, Description d) {<br \/>\n\t\t\tSystem.out.println(d.getMethodName() + \" FAILED\\n\" + logText);<br \/>\n\t\t}<br \/>\n\t};<\/p>\n<p>\t@After<br \/>\n\tpublic void tearDown () {<br \/>\n\t\tlogText = driver.findElement(By.id(\"test-log\")).getAttribute(\"value\");<br \/>\n\t}<br \/>\n}<br \/>\n<\/code><br \/>\n\u3053\u3093\u306a\u611f\u3058\u3067\u81ea\u524d\u306e\u30c6\u30b9\u30c8\u306e\u57fa\u5e95\u30af\u30e9\u30b9\u306b\u4ed5\u8fbc\u3093\u3067\u304a\u3051\u3070\u3001\u3053\u308c\u3092\u7d99\u627f\u3057\u305f\u500b\u3005\u306e\u30c6\u30b9\u30c8\u3067\u306f\u4f55\u3082\u8003\u3048\u308b\u3053\u3068\u306a\u304f\u52dd\u624b\u306b\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u540d\u524d\u304c\u51fa\u529b\u3055\u308c\u308b\u3002<\/p>\n<p>\u304f\u308f\u3057\u304f\u306f <a href=\"http:\/\/kentbeck.github.com\/junit\/javadoc\/4.10\/index.html?org\/junit\/rules\/TestWatcher.html\" target=\"_blank\">javadoc<\/a> \u3092\u898b\u308c\u3070\u5168\u90e8\u66f8\u3044\u3066\u3042\u308b\u3002<\/p>\n<div class=\"db9cc8cdb64025d13c1cc9dad0a0e262\" data-index=\"1\" style=\"float: left; margin: 16px 16px 16px 0;\">\n<script type=\"text\/javascript\"><!--\r\ngoogle_ad_client = \"ca-pub-5825700137064158\";\r\n\/* 250sq, appsweets-blog *\/\r\ngoogle_ad_slot = \"4837931762\";\r\ngoogle_ad_width = 250;\r\ngoogle_ad_height = 250;\r\n\/\/-->\r\n<\/script>\r\n<script type=\"text\/javascript\"\r\nsrc=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\r\n<\/script>\n<\/div>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>\u30b0\u30b0\u308c\u3070\u305f\u304f\u3055\u3093\u60c5\u5831\u306f\u5f97\u3089\u308c\u308b\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u30e1\u30e2\u3002 junit \u3067\u30c6\u30b9\u30c8\u3092\u66f8\u304f\u969b\u3001\u4eca\u4f55\u306e\u30c6\u30b9\u30c8\u3092\u3057\u3066\u3044\u308b\u306e\u304b\u2026\u2026\u306a\u3069\u306e\u30ed\u30b0\u3092\u5410\u304d\u305f\u3044\u3053\u3068\u304c\u3042\u308b\u3002\u4f8b\u3048\u3070 wasavi \u306e\u30c6\u30b9\u30c8\u3067\u3001\u4f55\u3089\u304b\u306e\u30df\u30b9\u304c\u3042\u3063\u3066\u3001WebDriverWait \u304c\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3059\u308b\u3068\u3059\u308b\u3002\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u81ea\u4f53\u306f catch \u7bc0\u3067\u53d7\u3051\u53d6\u308b\u306e\u3067\u3001\u305d\u3053\u3067\u5358\u306b System.out.println(&#8220;timed out!&#8221;); \u3059\u308c\u3070 ant \u304c\u4fdd\u5b58\u3059\u308b\u30ed\u30b0\u306b\u542b\u307e\u308c\u308b\u3002\u304c\u3001\u3069\u306e\u30c6\u30b9\u30c8\u3067\u767a\u751f\u3057\u305f\u304b\u307e\u3067\u306f\u308f\u304b\u3089\u306a\u3044\u3002 \u305d\u3053\u3067\u3001\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3067 @Test public void foo () { System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName()); } \u306a\u3069\u3068\u66f8\u3051\u3070\u30ed\u30b0\u306b\u30c6\u30b9\u30c8\u4e2d\u306e\u30e1\u30bd\u30c3\u30c9\u540d\u304c\u66f8\u304b\u308c\u308b\u306e\u3067\u5224\u5225\u3059\u308b\u6750\u6599\u306b\u306a\u308b\u3002\u3057\u304b\u3057\u3053\u308c\u306f\u3059\u3079\u3066\u306e\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306b\u57cb\u3081\u8fbc\u307e\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u306e\u3067\u3001\u3068\u3066\u3082\u7169\u96d1\u3060\u3002 \u3055\u3066 junit4 \u306b\u306f TestWatcher \u3068\u3044\u3046\u3082\u306e\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u3066\u3001\u30c6\u30b9\u30c8\u958b\u59cb\u30fb\u7d42\u4e86\u3001\u3042\u308b\u3044\u306f\u6210\u529f\u6642\u30fb\u5931\u6557\u6642\u306b\u4efb\u610f\u306e\u51e6\u7406\u3092\u306f\u3055\u3080\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u958b\u59cb\u30fb\u7d42\u4e86\u3068\u3044\u3046\u306e\u306f @Before \u3068 @After \u3068\u88ab\u3063\u3066\u3044\u308b\u304c\u3001\u3053\u308c\u3089\u306f\u3042\u304f\u307e\u3067\u30c6\u30b9\u30c8\u8996\u70b9\u3067\u306e\u958b\u59cb\u30fb\u7d42\u4e86\u306a\u306e\u306b\u5bfe\u3057\u3066\u3001TestWatcher \u306e\u305d\u308c\u306f\u30c6\u30b9\u30c8\u30e9\u30f3\u30ca\u30fc\u304b\u3089\u898b\u305f\u3001\u300c\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u300d\u306e\u958b\u59cb\u30fb\u7d42\u4e86\u3067\u3042\u308a\u3001\u30c6\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u306e\u7d20\u6027\u306a\u3069\u306e\u30e1\u30bf\u306a\u60c5\u5831\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002 import org.junit.*; import org.junit.rules.TestRule; import org.junit.rules.TestWatcher; import &hellip; <a href=\"https:\/\/appsweets.net\/blog\/2012\/09\/15\/watch-a-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5,13,3,4],"class_list":["post-433","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-javascript","tag-selenium","tag-vi","tag-wasavi"],"_links":{"self":[{"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/posts\/433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/comments?post=433"}],"version-history":[{"count":4,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/posts\/433\/revisions"}],"predecessor-version":[{"id":437,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/posts\/433\/revisions\/437"}],"wp:attachment":[{"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/media?parent=433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/categories?post=433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/tags?post=433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}