[컴][자바] easyb BDD framework 사용하기


how to run easybe / 이지비 /


easyb

easyb(http://easyb.org) 를 좀 사용해 봤다. BDD (Behavior Driven Development) 라는 개념에 관련해서 만들어진 test framework 이다. BDD 는 요구사항이 곧 test 의 형태로 작성되는 개념이라고 생각하면 간략한 이해는 될 듯 하다. BDD 와 관련해서는 ref. 1 을 참고하자.

easyb github : easyb/easyb-core · GitHub




download

http://easyb.org/download.html 에서 다운로드 할 수 있다. 다운로드하면 jar 이 있는 것을 확인할 수 있다.




사용법

easyb > An in-depth tutorial 을 한 번 읽어보자. 그러면 어느정도 간략한 사용법을 알 수 있다.




실행

여기에 가면 여러가지 실행방법을 확인할 수 있다.


command line


처음에 test.groovy 파일을 하나 만들고 실행해 봤다.
c:\>java -classpath easyb-0.9.jar;commons-cli-1.1.jar;groovy-1.5.4.jar org.disco.easyb.BehaviorRunner test.groovyYour file, test.groovy, cannot be run as its name or extension is ambigious. easyb behavior files must end in Story.groovy, .story, Specification.groovy or .specification.

그랬더니 이름에 문제가 있다고 했다. 에러를 살펴보니, Story 를 끝나는 이름의 .groovy 이거나, .story, .specification 으로 된 file 이어야 한다고 한다.

여하튼 그래서 MyStory.groovy 로 변경하고 실행했더니 잘 된다.

c:\> java -classpath easyb-0.9.jar;commons-cli-1.1.jar;groovy-1.5.4.jar org.disco.easyb.BehaviorRunner MyStory.groovy
Running my story (MyStory.groovy)
Scenarios run: 0, Failures: 0, Pending: 0, Time Elapsed: 0.34 sec

1 behavior run with no failures


classpath option

위에서 classpath 를 지정해 준 이유는 내 CLASSPATH 가 이상하게 동작을 안했다. set 은 되어 있었는데, 적용되지 않아서 어쩔 수 없이 -classpath 를 사용했다.


MyStory.groovy

MyStory.groovy 는 in-depth tutorial 의 내용을 가져왔다.

given "an empty stack",{
 stack = new Stack()
}

when "null is pushed", {
 pushnull = {
  stack.push(null)
 }
}

then "an exception should be thrown", {
 ensureThrows(RuntimeException){
  pushnull()
 }
}

and "then the stack should still be empty", {
 stack.empty.shouldBe true
} 



ant


 <property name="behaviors.dir" value="C:/Users/namhadmin/Documents/workspace/util-4/src/com/wowza/test4"/>
 <property name="lib.dir" value="C:/Users/namhadmin/Documents/workspace/libs"/>
 ...

 <taskdef name="easyb" classname="org.disco.easyb.ant.BehaviorRunnerTask">
  <classpath>
   <pathelement location="${lib.dir}/easyb-0.9.jar"/>
   <pathelement location="${lib.dir}/groovy-1.5.4.jar"/>
   <pathelement location="${lib.dir}/commons-cli-1.1.jar"/>
  </classpath>
 </taskdef>
 
 <easyb>
  <classpath>
   <pathelement path="bin" />
   
   <pathelement location="${lib.dir}/groovy-1.5.4.jar"/>
   <pathelement location="${lib.dir}/commons-cli-1.1.jar"/>
  </classpath>
  <report location="bin/story.txt" format="txtstory" />
  <behaviors dir="${behaviors.dir}">
   <include name="**/*Story.groovy"/>
  </behaviors>
 </easyb>



Reference

  1. Introducing Behavior Driven Development | Java.net

댓글 없음:

댓글 쓰기