Adopting Agile Tools & Methods In A Legacy Context

Preview:

DESCRIPTION

 

Citation preview

Xavier WarzeeEmail: xavier@warzee.fr

Blog: http://warzee.frSite: http://www.agilescale.com

Insurance applications

Talk based on one year engagementIn an insurance companyA subsidiary of one of the largest french bank

6 insurance applicationsUsed by several networks of regional insurance

agenciesRunning in a datacenter (Mainframes, Unix servers)

Legacy systemsApplications

Implemented in Java/J2EE running on Unix servers

No dependency injection, no cool frameworks (Spring, Hibernate, …)

Various size and maturity

Business rules and services Implemented in Cobol running on IBM

mainframesIBM MQ to communicate with applications

Tools & practicesBuilding and deployment of J2EE

applications with IBM RAD6 (based on Eclipse 3.0.1)

Software Configuration Managementwith IBM Rational Clearcase LT 2003 for

Java/J2EENothing for Cobol developments

No tests (unit & acceptance tests)

ObjectivesMain objectives

To develop the code really expected for each release

To prepare adoption of agile methods :-)

Short terms objectives based on the “follow the pain” principleShrink time to release new versions of J2EE

applicationsEase deployment of applicationsProvide adapted testing solutions to the legacy

context

Bottom-up Approach> pragmatic metrics : RTFsMonitor projects progress with RTFs (Running,

Tested Features)Running means here deployed to a Websphere

server (we have J2EE applications) => continuous deployment

Tested means a development is done when tested => automated tests during projects building

Features means make the latest developments available at any time => continuous integration of changes

Adoption strategy/audit> Identify steps to improve the developmentNo scripted building

Manual building under RAD6/EclipseCheckout code, check dependencies, package correctly

EAR/WAR1 to 3 days needed to check an application is correctly

packaged !

No scripted deploymentmanual deployment with the Websphere consoleError prone, need to know Websphere Application ServerNeed 1 or 2 days to deploy an application under WAS6.1

No code review to measure quality

And no tests!

Adoption plan proposed (1/3)

Use Maven to build applications/projects No longer use an IDE to build apps/projects

(error prone) Better traceability of packaged components

Develop scripts to deploy applications Jython Scripts used both by production and

development teams to deploy to Websphere AS 6.1

Avoid behavior gaps between dev and prod environments

Scripts called from Maven to automate deployment!

Adoption plan proposed (2/3)

Review projects with Maven to measure code quality

Simple declarative approach to configure code review tools PMD, Checkstyle, FindBugs Maven plugins!

Integrate code review reporting during nightly builds Just simply use the Maven build lifecycle

Implement Builds Management with CruisecontrolContinuous integration of changes (build, unit

tests)Nightly builds (build, tests, deploy & review)Support for pre-release builds (using a Clearcase

label)

Adoption plan proposed (3/3)

Implement unit tests with Junit, XMLUnit and JMockIt

Check code behaves as expected by developers !JMockit helps

to disconnect J2EE applications from MAINFRAME To test in isolation without modifying application codes

(bytecode rewriting)

Use acceptance tests with Fit/FitNessecheck code behaves as expected by users for each

releaseUse FitNesse plugin for RAD/Eclipse and for

MavenPost deployment tests to ensure full testability by

users

In a legacy context

Manual Acceptance

testingUsing the

GUI

Unit Tests

Automated tests ofthe GUI

• Simple• usual approach• manual and error-prone• traceability with requirements?

• Technical solution• Quick to run since automated• numerous similar tests to write• fragile tests (HTML may change)

• What do we test ? Priorities ?• How to identify tests to run ?• How to identify failing tests ?

Start Stop ?Start Stop Look

Mike Cohn tests pyramid adoption>> current practices!

Acceptance tests with the

GUI

FitNesse

Unit Tests

• Small number of tests• Try automate these tests

• Define accurate functional tests

• Unit tests generalized• Adopt a TDD approach

Start Stop ?Start Stop Look

Mike Cohn tests pyramid adoption> target practices: the pyramid of Mike Cohn

Mike Cohn tests pyramid adoption> pragmatic target practices!

Unit Tests

Acceptance tests with the

GUI

Automated acceptance

tests

• Try to reduce the number of tests(if any, use FitNesse + Selenium)

• Use Fit/FitNesse

• reach a high coverage of code• improve capacities of test with supporting tools (xUnit tools such as JMockIt, DbUnit, XMLUnit, JUnitPerf, JsUnit, …)

Start Stop Look

DAOBusiness Service

Business Component

Business Component

Business layer (EAR) Mainframe layer

Business

Service

(Cobol)

MQ

DAO

Business Service

MQ

Business Component

Presentation layer

(EAR)

EIARD Application

Application

Process

Service

Business Process

Service

DAS

HTML/JS/JSP

Pages

xml/http mq

Business

Service

(Cobol)

DAS

Functional testing with FitNesse> Business layer

Black box approachWiki to easy functional data injection!

Dossier component

Personne component

Business layer Mainframe layer

FunctionalService(Cobol)

MQ

DAO

BusinessService

FunctionalService(Cobol)

MQ

ElementStructure component

PMGestionCompteSUT

PMColumnFixture

DAS

DAO

BusinessService

DASPMListeDossiers

SUT

Selenium is powerfulIssues to set timeout when MQ access not mocked!

(JDBC/DB2)

CADOMDevisA4

Dossier component

Personne component

Business layer Mainframe layer

FunctionalService(Cobol)

MQ

CAD

OM

FunctionalService(Cobol)

MQ

ElementStructure component

Presentation layer

PUPerteMdp PMGestionCompte

SAD

PagesHTML/JS/JSP Request

Other systems

Selenium RC

Functional testing with FitNesse> Presentation layer with Selenium

EIARD application

SeleniumRunner

Testing scenarios> Car insurance quote scenario Write scenario in natural language with the FitNesse wikiUse the SeleniumRunner fixture to translate natural

languages into Selenium verbs (open, click, select, …)The SeleniumRunner fixture invokes a Selenium instance The Selenium instance interacts with the application !

FitNesse Tests & Continuous integration 1/3

1

3

Continuous integration server machine

- Windows Service : Selenium-RC

- Windows Service : FitNesse Server (port 9987)

Deployment Platform

SCM repository

(Clearcase, SVN, …)

2

6

4 5

1 – Check in (restitution)2 – Projects updated on the continuous

integration server 3 – Projects built :

compilation, application and tests resources generation, unit tests and components tests execution, code review,

4 – Projects deployment (when needed : EAR)5 – Acceptation tests executed using FitNesse

(and Selenium)6 – Notification by email

FitNesse Tests & Continuous integration 2/3> Maven command called by Cruisecontrol

Definition of a Maven profile: “fitnesse”To declare and configure Fitnesse

pluginTo set FitNesse parameters to use

Here for the Dossier project: <fitNesseServerName>s00sic001.ca-pacifica.fr</fitNesseServerName> <fitNesseServerPort>8081</fitNesseServerPort> <fitNesseServerPage>TestsAcceptation.TestsNm.TestsDossier</fitNe

sseServerPage>

Select a Maven project phaseAfter “package”:

ear applications are deployed to Websphere App Server during this phase !!!

Command to launch FitNesse tests mvn –Pfitnesse post-integration-test

(création du jar)

FitNesse Tests & Continuous integration 3/3Cruisecontrol builds applications with Maven

Maven launches FitNesse tests (if present) after application deployment

Cruisecontrol webapp adapted to collect FitNesse results in a new tab !

Adaptation de Cruisecontrol Ajout d’un onglet Fit (FitNesse est la surcouche

Wiki à Fit)

How to define scenarios? (1/3)Launch an application with Firefox (here e-

IARD)Select Tools -> “Selenium IDE”

How to define scenarios? (2/3)Complete forms for Car Insurance

Quote (“Simulation Assurance Automobile”)

Events captures by Selenium IDE

How to define scenarios? (3/3)

FitNesse Page

Integration ofThe FitNesse report

FitNesse reports> included in the web site generated by Maven

Eclipse/RAD plugins> Plugin Eclipse FitNesse (Band XI)

Boutons d’accés aux serveurs Fitnesse En local En remote

Incremental releases

Iterative releases

Recommended