atdd with cucumber

Post on 11-Nov-2014

804 Views

Category:

Technology

5 Downloads

Preview:

Click to see full reader

DESCRIPTION

ATDD with Cucumber

TRANSCRIPT

ATDD with

Cucumber최윤상

oddpoet@gmail.com

What is ATDD ?Acceptance Test Driven Development

What is ATDD ?Acceptance Test Driven Development

BDD(Behavior Driven Development)

What is ATDD ?Acceptance Test Driven Development

BDD(Behavior Driven Development)Specification by Example

TDD Cycle

Test in TDD

Test in TDD

specificationtest가 먼저 작성되니깐

Test in TDD

example code

specificationtest가 먼저 작성되니깐

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

Test in TDD

living documentation

example code

specificationtest가 먼저 작성되니깐

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

항상 최신 상태로 유지되는

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

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

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

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

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

Code를 못 보는

사람들까지도

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

TDD의 사이클

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

모두 함께 얘기하는 곳

개발자들끼리 노는 곳

“acceptance criteria”

“acceptance criteria”

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

작업의 완료 기준

테스트(예제)

기능에 대한 명세(문서)

“acceptance criteria”

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

작업의 완료 기준

테스트(예제)

기능에 대한 명세(문서)

모든 사람이 이해할 수 있는

Cucumber-JVM

Cucumber is

Cucumber is

Cucumber is

Cucumber-JVM ?!

Cucumber-JVM ?!

??

Cucumber is fororiginal

Cucumber is fororiginal

java 개발자는...

JAVA 개발자를 위한 Cucumber는?

JAVA 개발자를 위한 Cucumber는?

두둥~!

JAVA 개발자를 위한 Cucumber는?

두둥~!

그런데!!!

Aslak Hellesøy, Dan North 가

Cucumber 만들기전에 만들었다가

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

또다른 Cucumber for Java

+

또다른 Cucumber for Java

+

Cuke4Duke

또다른 Cucumber for Java

+

Cuke4Duke

또다른 Cucumber for Java

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

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

결국

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

(by Aslak Hellesøy)

결국

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

(by Aslak Hellesøy)

Cucumber-JVM

결국

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

(by Aslak Hellesøy)

Cucumber-JVM

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

Cucumber-JVM

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

cucumber-jvm 설정하기

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를����������� ������������������ 사용����������� ������������������

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

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

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

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

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

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

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

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

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

InteractiveStepDef.java  추가

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

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

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

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

Gherkin Basic

Gherkin

Gherkin

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Ubiquitous Language가 된다!

top related