Spock ã§ã¯ Groovy ã®åçãªç¹æ§ãçãããæè»ãª Mocking ãã¹ããå®ç¾ã§ãã¾ãã blog1.mammb.com ååã«ç¶ãã¦ãSpock ã®ã¢ãã¯æ©è½ã«ã¤ãã¦è¦ã¦ããã¾ãããã Mock ãä½æãã ã¤ã³ã¿ã©ã¯ã·ã§ã³ãæ¤è¨¼ãã Mock ã®æ¯èããå®ç¾©ãã Mock ãªãã¸ã§ã¯ãã®çæ ã¤ã³ã¿ã©ã¯ã·ã§ã³åæ°æ¡ä»¶ã®å®ç¾© å¼æ°ã®ãããã³ã°å®ç¾© ã¡ã½ããã®ãããã³ã°å®ç¾© ãããã³ã°ã®é åº Strict Mocking ã¢ãã¯çææã«ã¤ã³ã¿ã©ã¯ã·ã§ã³æ¡ä»¶ãæå®ãã ã¢ãã¯ã¨ã®ã¤ã³ã¿ã©ã¯ã·ã§ã³é åºãæ¤è¨¼ãã ã¹ã¿ãã®ä½æ ã¹ã¿ãããé åºå¤ãè¿å´ãã ã¹ã¿ãããçæããå¤ãè¿å´ãã ã¢ãã¯ã¨ã¹ã¿ããåããã¦ä½¿ã ã¹ã¿ãåã«ç¹åããStubsã使ã ã¹ã㤠ã¾ãã¯å ¬å¼ãµã³ãã«ããã®ä¾ã§ã以ä¸ã®ãããªã¤ãã³ãã® Publisher 㨠Subscriber ã®ã¤ã³ã¿ã©ã¯ã·ã§ã³ã«å¯¾ãã
This blog is more of a tutorial where we describe the development of a simple data access module, more for fun and learning than anything else. All code can be found here for those who donât want to type along: https://github.com/ricston-git/tododb As a heads-up, we will be covering the following: Using Groovy in a Maven project within Eclipse Using Groovy to interact with our database Testing our
ç¸äºä½ç¨ä¸å¿ã®ãã¹ã¶ ç¸äºä½ç¨ä¸å¿ã®ãã¹ãã¯2000年代ååã«ç»å ´ããExtreme Programmingï¼XPï¼ããçã¾ããè¨è¨ããã¹ãææ³ã§ãããªãã¸ã§ã¯ãã®ç¶æ ã§ã¯ãªããã¡ã½ããã®å¼ã³åºãã«ãã£ã¦ãä»æ§å¯¾è±¡ãªãã¸ã§ã¯ããã³ã©ãã¬ã¼ã¿ã¨ã©ã®ããã«ç¸äºä½ç¨ããã®ãã¨ããããªãã¸ã§ã¯ãã®æ¯ãèãã«æ³¨ç®ãã¾ãã ä¾ãã°è¤æ°ã®Subscriberã«ã¡ãã»ã¼ã¸ãéä¿¡ããPublisherãããã¨ãã¾ãããã class Publisher { List<Subscriber> subscribers void send(String message) } interface Subscriber { void receive(String message) } class PublisherSpec extends Specification { Publisher publisher =
ã¯ããã¾ãã¦ï¼Amebaäºæ¥æ¬é¨ãã©ãããã©ã¼ã Divã§ã¢ããªã±ã¼ã·ã§ã³ã¨ã³ã¸ãã¢ããã¦ããæ± ç°(@yukung)ã§ãã ç§ã¯2011å¹´5æã«å¤§æSIerãã転è·ãããµã¤ãã¼ã¨ã¼ã¸ã§ã³ãã¸å ¥ç¤¾ãã¾ãããåè·ã§ã¯ä¸»ã«éèæ¥çãã¿ã¼ã²ããã«ããBtoBåãã®ã·ã¹ãã éçºã«å¤ãæºãã£ã¦ãã¾ããããéçºä½æ¥ã®ä¸ã§ãããªçµé¨ãå²ã¨ãããããã¦ãã¾ããã ã»ã½ã¼ã¹ã³ã¼ããããã¥ã¡ã³ãã®ç®¡çã«ãã¼ã¸ã§ã³ç®¡çãã¼ã«ã使ããã«ãHoge_yyyyMMdd.javaã¨ãDBè¨è¨_yyyyMMdd.xlsã¿ãããªãã¡ã¤ã«ç®¡çããã¦ã©ããæ£ããããã¥ã¡ã³ããããããªããªãã«ãªã¹ã«ãªã ã»ã½ã¼ã¹ã³ã¼ãã®éçãã§ãã¯ãã¼ã«ï¼CheckStyleãFindbugsãªã©ï¼ã使ããã«ãç®è¦ã¨æ°åã§ã²ãããã½ã¼ã¹ã³ã¼ãã¬ãã¥ã¼ãã ã»Excel表ã§æ¸ããããã¹ãã±ã¼ã¹ãç¨ã¿ãªãããæã§ã±ã¼ã¹ã«æ²¿ã£ããªãã¬ã¼ã·ã§ã³ããã¦ããã
URL: http://www.grails.org/plugin/spock ãã©ã°ã¤ã³ã®ãã¼ã¸ã§ã³: 0.5 対å¿ããGrailsã®ãã¼ã¸ã§ã³: 1.2ä»¥ä¸ ã¯ããã«ä»åç´¹ä»ããGrailsãã©ã°ã¤ã³ã¯ãSpockãã©ã°ã¤ã³ã§ãã ãã®ãã©ã°ã¤ã³ãçµã¿è¾¼ããã¨ã«ãããSpockã使ã£ã¦ãã¹ãã±ã¼ã¹ãè¨è¿°ãããã¨ãã§ãã¾ãã Spockã¨ã¯Spockã¯ãJavaãGroovyç¨ã®ãã¹ãã¨ä»æ§ã®ããã®ãã¬ã¼ã ã¯ã¼ã¯ã§ãã Spockã«ã¤ãã¦ã¯ã次ã®URLãåç §ãã¦ãã ããã http://spockframework.org/ ãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«ãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«æé ã¯ãGrailsã®ãã¼ã¸ã§ã³ã«ãã£ã¦ç°ãªãã¾ãã Grails 1.2.xã®å ´åGrails 1.2.xã®å ´åã次ã®ã¨ããã§ãã $ grails install-plugin spock 0.5-groovy-1
ãEclipse ã§è¤æ°ã® Specification ãä¸æ¬å®è¡ããã㧠å®ã¯ Spock ã«ã¯ Junit ã®ãã¹ãã¹ã¤ã¼ãã®ãããªæ©è½ã¯ããã¾ããã ã¤ã¾ããSpock èªèº«ã«ã¯ è¤æ°ã® Specification ãä¸æ¬ã§å®è¡ããæ©è½ã¯ãªãã®ã§ãã Eclipse ã§è¤æ°ã® Specification ãä¸æ¬å®è¡ãã - bluepapa32âs Java Blog ãªãã¦ãã¨ãæ¸ãã¦ãã¾ãã¾ããã Spock ã§ã ã¡ããã¨ãã¹ãã¹ã¤ã¼ãã§ãã¾ãã ã¨è¨ãã®ã... Spock ã® Specification 㯠Junit4 ã®ä»çµã¿ã§åãã¦ããã®ã§ Junit4 ã®ãã¹ãã¹ã¤ã¼ãã¨åãããã« package com.bluepapa32; import org.junit.runner.RunWith; import org.junit.runners.Suite; impo
Groovy/Grailsã®æ¯ãèãé§åéçº (Behavior-driven Development, BDD) ãã¬ã¼ã ã¯ã¼ã¯ Spockã®ä½¿ãæ¹ (é¦è¨³) Spockã®åºç¤ Spockä»æ§ã解åããã ãã®ç« ã§ã¯, Groovyã¨Unitãã¹ãã«ã¤ãã¦ã®åºæ¬çãªç¥èã¯æã£ã¦ãããã®ã¨ãã¾ã. ãã, ããªããJavaããã°ã©ãã§, Groovyã«ã¤ãã¦ã¯ä½ãç¥ããªãã¨ãã¦ã, å¿é ã¯è¦ãã¾ãã. Groovyã¯ããªãã«ã¨ã£ã¦ãã¨ã¦ããªãã¿æ·±ããã®ã«ãªãã¨æãã¾ãã! å®é, Groovyã®ä¸»è¦ãªè¨è¨ç®æ¨ã®ä¸ã¤ã¯Javaã«æ²¿ã£ãã¹ã¯ãªããè¨èªã¨ãªããã¨ãªã®ã§ã. å¿ è¦ã«å¿ã㦠Groovyã®ããã¥ã¡ã³ã ãåç §ãã¦ãã ãã. ãã®ç« ã®ç®ç㯠ç¾å®çãªSpockä»æ§ãæ¸ããã¾ã§Spockã«ã¤ãã¦å¦ã¶ ããªãã®å¥½å¥å¿ãããç«ã¦ã ãã¨ã§ã. Groovyã«ã¤ãã¦ãã£ã¨ããç¥ãããã«ã¯, h
社å ã®åå¼·ä¼ã§ãªããããã¹ãã¼ã£ã¦ãã¨ã«ãªãããªãã¨ãªãSpockãã©ã£ãã§æ°ã«ãªã£ã¦ãã®ã§ãSpockã©ãããGroovyãã触ã£ããã¨ã»ã¼ãªãã§ããã©ãããã¥ã¡ã³ãããµã©ã¼ã£ã¨èªãã§é¢ç½ããªã¼ã¨æãã¨ãããSpock Web Consoleã§åããã¤ã¤ç´¹ä»ãã¦ã¿ãããã¾ããï¼å¾©ç¿ãã¦ããããã¡ã©èªãã§ã¿ã¾ããã Spock Web Console http://meetspock.appspot.com/ SpockBasics https://code.google.com/p/spock/wiki/SpockBasics Example å ¨ä½ã¯ãããªæãããªãèªã¿ããããã class MyFirstSpecification extends Specification { def "pushing an element on the stack"() { setup: def s
Spockã¨ã¯ Spockã¯JavaãGroovyåãã®ãã¹ããã¬ã¼ã ã¯ã¼ã¯ã§ãã JUnitãªã©ã¨æ¯è¼ãã¦ä»¥ä¸ã®ç¹ã使ããããã§ãã ãã¼ã¿ããªãã³ãªãã¹ããæ¸ãããã Mockãæ¸ãããã ãã¹ãçµæãè¦ããã(PowerAssert) åºæ¬çãªä½¿ãæ¹ã¯ãã¡ãæ¹ã®ããã°ã«ããããããæ¸ããã¦ãã¾ãã http://bufferings.hatenablog.com/entry/2014/01/17/234736 ããããã㨠ãã¼ã¿ãã¼ã¹ã«ã¢ã¯ã»ã¹ãããã¹ãã³ã¼ããæ¸ãå ´åããã¹ãéå§æã«ãã¼ã¿ãã¼ã¹ã«ãã¹ãç¨ã®ãã¼ã¿ãæµãããã¹ããçµäºãããå ã®ãã¼ã¿ã復å ããã¨ãããã¨ãè¡ããã¨ä¾¿å©ã§ãã ãããæ®å¿µãªãããSpockã«ã¯ãã®ä»çµã¿ãç¨æããã¦ããªãããDbUnitã®ãããªãã¼ã¿ãã¼ã¹ãæä½ããä»çµã¿ãå¿ è¦ã«ãªãã¾ãã ä»åã¯Spockã¨DbUnitãé£æºããã¦ãä¸è¨ã®ä»çµã¿ãä½ã£
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}