Está en la página 1de 86

Test-Driven Development on a Large Scale Project

Speaker
Jan Van Reusel

1997

Speaker
Jan Van Reusel

1997

1999

Speaker
Jan Van Reusel

1997

1999

2002

Speaker
Jan Van Reusel

1997

1999

2002

2003

2003

Speaker
Jan Van Reusel

Speaker
Development Manager

Speaker
What keeps me awake at night?

...sometimes...

...more often...

...summer 2005...

...summer 2006...
12

Load factor
10

0 05/05 07/05 09/05 11/05 01/06 03/06 05/06 07/06 09/06

This Session
What did we do about it?

Context
Ventouris Renewal Program

Accountancy Bank Self-employed activity Look up and process income data Career data Continued insurance Payments receive reassign reimburse

Bailiff

Request remission / exemption

Modifications
FCP

Debt administration Reminder Summons Subpoena

Calculation

File
Family allowance

Discharge Pension Decease Failure (insurance) Normal suspension: request equalization continued insurance

NISSE
Self-employed Affiliation Suspension

customers

team size

60

100 my 3 year

Application clients
HTML Browser Web Service Client NISSE Batch Client

Presentation Layer
<<JSF>> Web User Interface

Service Layer
<<Session Bean>> Application Services <<JCAPS>> BPEL Engine <<POJO / MDB>> NISSE Gateway <<POJO / MDB>> Batch Dispatcher

Domain Layer
<<POJO>> Business Object <<JESS>> Rule Engine

Data Source Layer


<<JDO>> Domain Store <<POJO / MDB>> File Gateway <<POJO>> Document Gateway

Application Infrastructure
<<Oracle>> Database File System <<Scriptura>> Document Generator

Design Documentation Scope Trust

Why TDD?

Business Facing Support Programming Exploratory (proxy) Integration (XML) Exploratory (customer) System Alfa Beta Unit Integration (Java) Data conversion Performance Fail over Critique Product

Technology Facing
Brian Marick

Test Strategy

Developer 1 Machine Build/Test Process Developer 2 Machine Build/Test Process Developer 3 Machine Build/Test Process Application Server Application Server Application Server

Database Server

Database Schema 1 Schema 2 Schema 3

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

http://xunitpatterns.com

Replace code on which SUT depends

http://xunitpatterns.com

http://xunitpatterns.com

http://xunitpatterns.com

Control indirect input

http://xunitpatterns.com

Verify indirect output

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

Mock Object or Test Stub


Business Object Business Object Gateway

JSF Component

Facade Impl

Managed Bean

Persistence Manager

JDO

RDBMS

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

Test Helper

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

http://xunitpatterns.com

http://www.thoughtworks.com/object-mother-easing-test-object-creation.pdf

Object Mother

Object Mother
Test Helper

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

Humble Object
JSF Component Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

Mock Object

Mock Object or Test Stub

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver

Browser Process Selenium Browser Bot

AUT

Selenium Server Selenese Proxy WebApp

Web Server AUT WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


1. Launches

Browser Process Selenium Browser Bot

AUT

Selenium Server Selenese Proxy WebApp

Web Server AUT WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


1. Launches

Browser Process Selenium Browser Bot

AUT
2. Requests command

Selenium Server Selenese Proxy WebApp

Web Server AUT WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


1. Launches

Browser Process Selenium Browser Bot

AUT
2. Requests command

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot

AUT
2. Requests command

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot

AUT
2. Requests command

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot

AUT
2. Requests command 5. Go to AUT

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot


6. Go to AUT

AUT
2. Requests command 5. Go to AUT

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot


6. Go to AUT

AUT
2. Requests command 5. Go to AUT 7. HTTP Request

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot


6. Go to AUT

AUT
2. Requests command 5. Go to AUT 7. HTTP Request 8. HTTP Response

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot


6. Go to AUT 9. Gets result

AUT
2. Requests command 5. Go to AUT 7. HTTP Request 8. HTTP Response

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot


6. Go to AUT 9. Gets result

10. Returns result & requests command

AUT
7. HTTP Request 8. HTTP Response

2. Requests command

5. Go to AUT

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 1. Launches

Browser Process Selenium Browser Bot


6. Go to AUT 9. Gets result

10. Returns result & requests command

AUT
7. HTTP Request 8. HTTP Response

2. Requests command

5. Go to AUT

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp


11. Waits

http://www.openqa.org/selenium

JUnit Test Process Selenium Driver


4. Go to AUT & request result 12. Result 1. Launches

Browser Process Selenium Browser Bot


6. Go to AUT 9. Gets result

10. Returns result & requests command

AUT
7. HTTP Request 8. HTTP Response

2. Requests command

5. Go to AUT

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp


11. Waits

http://www.openqa.org/selenium

JUnit Test Process

13. Asserts on result 1. Launches

Browser Process Selenium Browser Bot


6. Go to AUT 9. Gets result

Selenium Driver
4. Go to AUT & request result 12. Result

10. Returns result & requests command

AUT
7. HTTP Request 8. HTTP Response

2. Requests command

5. Go to AUT

Selenium Server
3. Waits

Web Server AUT WebApp

Selenese Proxy WebApp


11. Waits

import com.thoughtworks.selenium.*; import junit.framework.*; public class GoogleTest extends TestCase { private Selenium sel; public void setUp() { sel = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com"); sel.start(); } public void testGoogle() { sel.open("http://www.google.com/webhp"); sel.type("q", "hello world"); sel.click("btnG"); sel.waitForPageToLoad("5000"); assertEquals("hello world - Google Search", sel.getTitle()); } public void tearDown() { sel.stop(); } }

Test Smells

12

Load factor
10

0 05/05 07/05 09/05 11/05 01/06 03/06 05/06 07/06 09/06

Buggy Tests

Buggy Tests

12

Load factor
10

0 05/05 07/05 09/05 11/05 01/06 03/06 05/06 07/06 09/06

High Test Maintenance Cost

High Test Maintenance Cost

High Test Maintenance Cost

High Test Maintenance Cost

http://xunitpatterns.com

High Test Maintenance Cost

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain Mock Object


Business Object Business Object

Data Source

Infrastructure

Gateway

JSF Component

Facade Impl

Managed Bean

Persistence Manager

JDO

RDBMS

Mock Object

High Test Maintenance Cost

High Test Maintenance Cost

High Test Maintenance Cost

High Test Maintenance Cost

High Test Maintenance Cost

12

Load factor
10

0 05/05 07/05 09/05 11/05 01/06 03/06 05/06 07/06 09/06

Slow Tests

Slow Tests

Slow Tests

Slow Tests

Mock Object Client


Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

Slow Tests

Slow Tests

Slow Tests

Not Enough

HRS build time

test maintenance

Not Enough Lost ability to


respond to change

Not many tests Enough Too


too much overlap

Not Enough Slow component usage

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

Not Enough
Test type predeploy postdeploy number 5020 2606 % 66 34 time 170 5072 % 3 97

Not Enough
Test type predeploy postdeploy number 5020 2606 % 66 34 time 170 5072 % 3 97

Reduce to smoke tests

Result!
10 minute build

Client
Browser

Presentation
Faces Servlet

Service
Session Facade

Domain

Data Source

Infrastructure

JSF Component

Facade Impl

Business Object Business Object

Gateway

Managed Bean

Persistence Manager

JDO

RDBMS

Continuous design well! sts as Te Educate your team Be agile with test strategy

Conclusion

More? Agile Applied on The Largest J2EE Project in The Benelux by Johan Lybaert Agile Development Workshop by Kathleen Cornelis www.ardatissoftwarefactory.com

También podría gustarte