atdd with cucumber

70
ATDD with Cucumber 최윤상 [email protected]

Upload: yunsang-choi

Post on 11-Nov-2014

807 views

Category:

Technology


5 download

DESCRIPTION

ATDD with Cucumber

TRANSCRIPT

Page 1: Atdd with Cucumber

ATDD with

Cucumber최윤상

[email protected]

Page 2: Atdd with Cucumber

What is ATDD ?Acceptance Test Driven Development

Page 3: Atdd with Cucumber

What is ATDD ?Acceptance Test Driven Development

BDD(Behavior Driven Development)

Page 4: Atdd with Cucumber

What is ATDD ?Acceptance Test Driven Development

BDD(Behavior Driven Development)Specification by Example

Page 5: Atdd with Cucumber

TDD Cycle

Page 6: Atdd with Cucumber

Test in TDD

Page 7: Atdd with Cucumber

Test in TDD

specificationtest가 먼저 작성되니깐

Page 8: Atdd with Cucumber

Test in TDD

example code

specificationtest가 먼저 작성되니깐

개발자들간의 의사소통 수단이 되는

Page 9: Atdd with Cucumber

Test in TDD

living documentation

example code

specificationtest가 먼저 작성되니깐

개발자들간의 의사소통 수단이 되는

항상 최신 상태로 유지되는

Page 10: Atdd with Cucumber

개발자들끼리는 “(테스트) 코드”를 까보면 서로 이해할 수 있다

Page 11: Atdd with Cucumber
Page 12: Atdd with Cucumber

하지만 다른 사람은 우리를 그런식으로 이해하지 않아요

Page 13: Atdd with Cucumber

우리도 그들을 그렇게 이해하지 않죠

Page 14: Atdd with Cucumber
Page 15: Atdd with Cucumber

어떻게 하면 프로젝트의 모든 사람이 같은 언어로 얘기할 수 있을까?

Page 16: Atdd with Cucumber

어떻게 하면 프로젝트의 모든 사람이 같은 언어로 얘기할 수 있을까?

Code를 못 보는

사람들까지도

Page 17: Atdd with Cucumber

개발자와 비개발자가 같은 언어로 소통할 수 있는 지점?

Page 18: Atdd with Cucumber

TDD의 사이클

ATDD의 사이클기획자/개발자/QA/디자이너

모두 함께 얘기하는 곳

개발자들끼리 노는 곳

“acceptance criteria”

Page 19: Atdd with Cucumber

“acceptance criteria”

사용자 스토리에 대한 시나리오

작업의 완료 기준

테스트(예제)

기능에 대한 명세(문서)

Page 20: Atdd with Cucumber

“acceptance criteria”

사용자 스토리에 대한 시나리오

작업의 완료 기준

테스트(예제)

기능에 대한 명세(문서)

모든 사람이 이해할 수 있는

Page 21: Atdd with Cucumber

Cucumber-JVM

Page 22: Atdd with Cucumber

Cucumber is

Page 23: Atdd with Cucumber

Cucumber is

Page 24: Atdd with Cucumber

Cucumber is

Page 25: Atdd with Cucumber
Page 26: Atdd with Cucumber
Page 27: Atdd with Cucumber
Page 28: Atdd with Cucumber
Page 29: Atdd with Cucumber

Cucumber-JVM ?!

Page 30: Atdd with Cucumber

Cucumber-JVM ?!

??

Page 31: Atdd with Cucumber

Cucumber is fororiginal

Page 32: Atdd with Cucumber

Cucumber is fororiginal

java 개발자는...

Page 33: Atdd with Cucumber

JAVA 개발자를 위한 Cucumber는?

Page 34: Atdd with Cucumber

JAVA 개발자를 위한 Cucumber는?

두둥~!

Page 35: Atdd with Cucumber

JAVA 개발자를 위한 Cucumber는?

두둥~!

그런데!!!

Aslak Hellesøy, Dan North 가

Cucumber 만들기전에 만들었다가

더이상 손 안대고 있는....

Page 36: Atdd with Cucumber

또다른 Cucumber for Java

Page 37: Atdd with Cucumber

+

또다른 Cucumber for Java

Page 38: Atdd with Cucumber

+

Cuke4Duke

또다른 Cucumber for Java

Page 39: Atdd with Cucumber

+

Cuke4Duke

또다른 Cucumber for Java

이 역시 Aslak Hellesøy의 실패작!

실행도 잘 안되고, 2년 전쯤 완전히 버림

Page 40: Atdd with Cucumber

결국

Cucumber를 Java로 재개발하기로 결정!

(by Aslak Hellesøy)

Page 41: Atdd with Cucumber

결국

Cucumber를 Java로 재개발하기로 결정!

(by Aslak Hellesøy)

Cucumber-JVM

Page 42: Atdd with Cucumber

결국

Cucumber를 Java로 재개발하기로 결정!

(by Aslak Hellesøy)

Cucumber-JVM

JVM 상의 언어는 죄다 지원해주마!

Page 43: Atdd with Cucumber

Cucumber-JVM

이제����������� ������������������ cucumber����������� ������������������ ruby를����������� ������������������ 버리는����������� ������������������ 중?

Page 44: Atdd with Cucumber

cucumber-jvm 설정하기

Page 45: Atdd with Cucumber

pom.xml����������� ������������������ 에����������� ������������������ dependency����������� ������������������ 추가

junit과����������� ������������������ 연동

java를����������� ������������������ 쓸����������� ������������������ 경우����������� ������������������ 필수����������� ������������������

spring����������� ������������������ F/W과����������� ������������������ 연동

주의����������� ������������������ 1:����������� ������������������ junit은����������� ������������������ 4.11����������� ������������������ 이상을����������� ������������������ 쓸것����������� ������������������ (junit����������� ������������������ 4.8에서����������� ������������������ 오류����������� ������������������ 있음)����������� ������������������ 주의����������� ������������������ 2:����������� ������������������ cucumber-jvm����������� ������������������ 최신은����������� ������������������ 1.1.3이지만,����������� ������������������ pretty����������� ������������������ formatter����������� ������������������ 이슈가����������� ������������������ 있어서����������� ������������������ 1.1.2를����������� ������������������ 사용����������� ������������������

Page 46: Atdd with Cucumber

src/test/java/features/CucumberTests.java  생성

-����������� ������������������ junit����������� ������������������ runner����������� ������������������ 를����������� ������������������ 이용하여����������� ������������������ 실행된다.����������� ������������������

-����������� ������������������ options의����������� ������������������ features����������� ������������������ 경로의����������� ������������������ *.feature����������� ������������������ 파일을����������� ������������������ 읽어서����������� ������������������ 테스트를����������� ������������������ 실행한다.����������� ������������������

-����������� ������������������ format����������� ������������������ 옵션으로����������� ������������������ 출력형식을����������� ������������������ 지정할����������� ������������������ 수����������� ������������������ 있다.����������� ������������������

Page 47: Atdd with Cucumber

src/test/resources/features����������� ������������������ 디렉토리����������� ������������������ 생성main.feature����������� ������������������ 파일����������� ������������������ 추가

Page 48: Atdd with Cucumber

CucumberTests.java를����������� ������������������ JUNIT으로����������� ������������������ 다시����������� ������������������ 실행

step����������� ������������������ definition이����������� ������������������ 없다고����������� ������������������ 툴툴����������� ������������������ 거리면서,����������� ������������������ ����������� ������������������

code����������� ������������������ snippets을����������� ������������������ 출력해줌.����������� ������������������

Page 49: Atdd with Cucumber

src/test/java/features/steps  디렉토리����������� ������������������ 생성

InteractiveStepDef.java  추가

-����������� ������������������ 아직����������� ������������������ 개발된����������� ������������������ 코드가����������� ������������������ 없으므로����������� ������������������ pending����������� ������������������ 처리.����������� ������������������ ����������� ������������������

-����������� ������������������ yellow(pending)����������� ������������������ ->����������� ������������������ red(fail)����������� ������������������ ->����������� ������������������ green(success)

Page 50: Atdd with Cucumber

feature����������� ������������������ 개발����������� ������������������ 및����������� ������������������ step����������� ������������������ definition을����������� ������������������ 만들고����������� ������������������ 실행하면...

test����������� ������������������ result����������� ������������������ 이면서,����������� ������������������ ����������� ������������������ 스펙����������� ������������������ 문서가����������� ������������������ 생성됨

Page 51: Atdd with Cucumber

Gherkin Basic

Page 52: Atdd with Cucumber

Gherkin

Page 53: Atdd with Cucumber

Gherkin

Page 54: Atdd with Cucumber

Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behaviour without detailing how that behaviour is implemented.!

Gherkin serves two purposes – documentation and automated tests. The third is a bonus feature – when it yells in red it’s talking to you, telling you what code you should write.

Gherkin

Page 55: Atdd with Cucumber

Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behaviour without detailing how that behaviour is implemented.!

Gherkin serves two purposes – documentation and automated tests. The third is a bonus feature – when it yells in red it’s talking to you, telling you what code you should write.

Gherkin

Page 56: Atdd with Cucumber

Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behaviour without detailing how that behaviour is implemented.!

Gherkin serves two purposes – documentation and automated tests. The third is a bonus feature – when it yells in red it’s talking to you, telling you what code you should write.

Gherkin

Page 57: Atdd with Cucumber

Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behaviour without detailing how that behaviour is implemented.!

Gherkin serves two purposes – documentation and automated tests. The third is a bonus feature – when it yells in red it’s talking to you, telling you what code you should write.

Gherkin

Page 58: Atdd with Cucumber

Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behaviour without detailing how that behaviour is implemented.!

Gherkin serves two purposes – documentation and automated tests. The third is a bonus feature – when it yells in red it’s talking to you, telling you what code you should write.

Gherkin

Page 59: Atdd with Cucumber

Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behaviour without detailing how that behaviour is implemented.!

Gherkin serves two purposes – documentation and automated tests. The third is a bonus feature – when it yells in red it’s talking to you, telling you what code you should write.

Gherkin

구현����������� ������������������ 방법이����������� ������������������ 아니라����������� ������������������ 시스템의����������� ������������������ 기대행동을����������� ������������������ 묘사

Page 60: Atdd with Cucumber

Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behaviour without detailing how that behaviour is implemented.!

Gherkin serves two purposes – documentation and automated tests. The third is a bonus feature – when it yells in red it’s talking to you, telling you what code you should write.

Gherkin

구현����������� ������������������ 방법이����������� ������������������ 아니라����������� ������������������ 시스템의����������� ������������������ 기대행동을����������� ������������������ 묘사

requirements

features

design

coding

Page 61: Atdd with Cucumber

Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behaviour without detailing how that behaviour is implemented.!

Gherkin serves two purposes – documentation and automated tests. The third is a bonus feature – when it yells in red it’s talking to you, telling you what code you should write.

Gherkin

구현����������� ������������������ 방법이����������� ������������������ 아니라����������� ������������������ 시스템의����������� ������������������ 기대행동을����������� ������������������ 묘사

requirements

features

design

codingcucumber

unit����������� ������������������  test

Page 62: Atdd with Cucumber

gherkin����������� ������������������ featurefeature����������� ������������������ 제목

기능에����������� ������������������ 대한����������� ������������������ 설명����������� ������������������ (사용자����������� ������������������ 스토리)����������� ������������������ test����������� ������������������ 실행과는����������� ������������������ 무관한����������� ������������������ 문서����������� ������������������ 요소

기능에����������� ������������������ 대한����������� ������������������ 시나리오를����������� ������������������ ����������� ������������������ example����������� ������������������ 형태로����������� ������������������ 기술

다수의����������� ������������������ 시나리오로����������� ������������������ 구성할����������� ������������������ 수����������� ������������������ 있음

다수의����������� ������������������ Step(Given/When/Then)으로����������� ������������������ 구성됨

Page 63: Atdd with Cucumber

scenario����������� ������������������ background����������� ������������������

모든����������� ������������������ 시나리오가����������� ������������������ 동일한����������� ������������������ Given(조건)을����������� ������������������ ����������� ������������������ 가질����������� ������������������ 경우����������� ������������������ Background����������� ������������������ 절로����������� ������������������ 구성함

Page 64: Atdd with Cucumber

scenario����������� ������������������ outline����������� ������������������

-����������� ������������������ 예제의����������� ������������������ 값만����������� ������������������ 다른����������� ������������������ 동일한����������� ������������������ 시나리오들이����������� ������������������ 필요할����������� ������������������ 경우����������� ������������������ 사용함����������� ������������������ -����������� ������������������ 내부적으로����������� ������������������ 다수의����������� ������������������ 시나리오����������� ������������������ 처럼����������� ������������������ 처리함����������� ������������������ -����������� ������������������ Fit/FitNesse와����������� ������������������ 유사한����������� ������������������ Fixture����������� ������������������ 구성����������� ������������������

Page 65: Atdd with Cucumber

data����������� ������������������ table

-����������� ������������������ Step(Given/When/Then)����������� ������������������ 등에서����������� ������������������ 테이블����������� ������������������ 형태의����������� ������������������ 데이터를����������� ������������������ 기술할����������� ������������������ 때����������� ������������������ -����������� ������������������ StepDefinition에서����������� ������������������ DataTable����������� ������������������ API로����������� ������������������ 각����������� ������������������ cell에����������� ������������������ 접근하여����������� ������������������ 사용

-����������� ������������������ 혹은����������� ������������������ DataTable����������� ������������������ transformation도����������� ������������������ 가능����������� ������������������

Page 66: Atdd with Cucumber

doc����������� ������������������ string

-����������� ������������������ multiline����������� ������������������ string의����������� ������������������ 처리가����������� ������������������ 필요한����������� ������������������ 경우����������� ������������������ 사용함����������� ������������������

Page 67: Atdd with Cucumber

String����������� ������������������ Transformations

-����������� ������������������ StepDefinition에서����������� ������������������ String이����������� ������������������ 아닌����������� ������������������ 다른����������� ������������������ 객체로����������� ������������������ 받으려는����������� ������������������ 경우

-����������� ������������������ int,����������� ������������������ long,����������� ������������������ date,����������� ������������������ calendar����������� ������������������ 등은����������� ������������������ 기본����������� ������������������ 지원함

@Transform����������� ������������������ 어노테이션을����������� ������������������ ����������� ������������������ 사용하여����������� ������������������ 직접����������� ������������������ 변환을����������� ������������������ 할����������� ������������������ 수도����������� ������������������ 있음.����������� ������������������

Page 68: Atdd with Cucumber

Gherkin에 작성된 각 Step은 그 프로젝트에서의

Ubiquitous Language가 된다!

Page 69: Atdd with Cucumber
Page 70: Atdd with Cucumber