61
Testing and Migration Tudor Gîrba www.tudorgirba.com

Migration and Testing (EVO 2008)

Embed Size (px)

DESCRIPTION

I used this set of slides for a lecture I gave at the University of Bern on Dec 4, 2008.

Citation preview

Page 1: Migration and Testing (EVO 2008)

Testing and Migration

Tudor Gîrbawww.tudorgirba.com

Page 2: Migration and Testing (EVO 2008)

restructuring

reve

rse

engin

eerin

gforward engineering

}

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Page 3: Migration and Testing (EVO 2008)

restructuring }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Page 4: Migration and Testing (EVO 2008)

Testing and Migration

Page 5: Migration and Testing (EVO 2008)

Why test?

Page 6: Migration and Testing (EVO 2008)
Page 7: Migration and Testing (EVO 2008)

Many legacy systems don’t have tests

Page 8: Migration and Testing (EVO 2008)

Many legacy systems don’t have tests

Customers pay for features, not tests

Page 9: Migration and Testing (EVO 2008)

Many legacy systems don’t have tests

Customers pay for features, not tests

You can’t test everything anyway

Page 10: Migration and Testing (EVO 2008)

Many legacy systems don’t have tests

Customers pay for features, not tests

You can’t test everything anyway

Testing is akin to street-cleaning

Page 11: Migration and Testing (EVO 2008)

Many legacy systems don’t have tests

Customers pay for features, not tests

You can’t test everything anyway

Testing is akin to street-cleaning

Real programmers don’t need tests

Page 12: Migration and Testing (EVO 2008)

Write tests to enable evolution

Page 13: Migration and Testing (EVO 2008)

setUp

assert

tearDown

Use a testing framework

Page 14: Migration and Testing (EVO 2008)

Grow your test base incrementally

Page 15: Migration and Testing (EVO 2008)

Test the interface, not the implementation

Page 16: Migration and Testing (EVO 2008)

Record business rules as tests

Page 17: Migration and Testing (EVO 2008)

Write tests to understand

Page 18: Migration and Testing (EVO 2008)

setUp

assert

tearDown

Use a testing framework

Page 19: Migration and Testing (EVO 2008)

setUp

assert

tearDown

But, legacy is difficult to set up

Page 20: Migration and Testing (EVO 2008)

aModel aClass

add(aClass)

aStorage

store(aClass)

setModel(aModel)

Page 21: Migration and Testing (EVO 2008)

Ducasse etal 2006

aModel aClass

add(aClass)

aStorage

store(aClass)

setModel(aModel)

Page 22: Migration and Testing (EVO 2008)

Testing and Migration

Page 23: Migration and Testing (EVO 2008)

Migration is a restructuring thatchanges the underlying infrastructure

Page 24: Migration and Testing (EVO 2008)

1989

Page 25: Migration and Testing (EVO 2008)
Page 26: Migration and Testing (EVO 2008)

Big-bang migration often fails

Page 27: Migration and Testing (EVO 2008)

Big-bang migration often fails

Users hate change

Page 28: Migration and Testing (EVO 2008)

Big-bang migration often fails

Users hate change

You need constant feedback to stay on track

Page 29: Migration and Testing (EVO 2008)

Big-bang migration often fails

Users hate change

You need constant feedback to stay on track

Users just want to get their work done

Page 30: Migration and Testing (EVO 2008)

Big-bang migration often fails

Users hate change

You need constant feedback to stay on track

Users just want to get their work done

The legacy data must be available during the transition

Page 31: Migration and Testing (EVO 2008)

Involve the users

Page 32: Migration and Testing (EVO 2008)

Build confidence

Page 33: Migration and Testing (EVO 2008)

Conserve familiarity

Page 34: Migration and Testing (EVO 2008)

Migrateincrementally

Page 35: Migration and Testing (EVO 2008)

Prototype the target solution

Page 36: Migration and Testing (EVO 2008)
Page 37: Migration and Testing (EVO 2008)
Page 38: Migration and Testing (EVO 2008)

Throw-away vs. evolutionary prototypes

Page 39: Migration and Testing (EVO 2008)

Always have a running version

Page 40: Migration and Testing (EVO 2008)

Test after every change

Page 41: Migration and Testing (EVO 2008)

Use the profiler before optimizing

Page 42: Migration and Testing (EVO 2008)

Data needs to be preserved and available

Page 43: Migration and Testing (EVO 2008)

:Legacy System

:Legacy Storage

Page 44: Migration and Testing (EVO 2008)

:Legacy System :New System

:Legacy Storage :New Storage

Page 45: Migration and Testing (EVO 2008)

:Legacy System :New System

:Legacy Storage :New Storage

:Bridge

Page 46: Migration and Testing (EVO 2008)

:Legacy System :New System

:Legacy Storage :New Storage

:Bridge

Page 47: Migration and Testing (EVO 2008)

:Legacy System :New System

:Legacy Storage :New Storage

:Bridge

Make a bridge to the new town

Page 48: Migration and Testing (EVO 2008)

Present the right interface

Page 49: Migration and Testing (EVO 2008)

Public vs. published interface

Page 50: Migration and Testing (EVO 2008)

Componentservice()

Page 51: Migration and Testing (EVO 2008)

Componentservice()replacingService()

Page 52: Migration and Testing (EVO 2008)

Componentservice()replacingService()

Deprecate obsolete interfaces

Page 53: Migration and Testing (EVO 2008)

Componentservice()replacingService()

Deprecate obsolete interfaces

Page 54: Migration and Testing (EVO 2008)

Component replacingService()

Page 55: Migration and Testing (EVO 2008)

Componentservice()replacingService()

Is it a breaking or non-breaking change?

Page 56: Migration and Testing (EVO 2008)

Dig, Johnson 2006

Componentservice()replacingService()

80% of breaking API changes are due to refactorings

Page 57: Migration and Testing (EVO 2008)

Client, v1

Component, v1

Page 58: Migration and Testing (EVO 2008)

storechanges

Client, v1

Component, v1 Component, v2

Page 59: Migration and Testing (EVO 2008)

Dig etal 2007

storechanges

replaychanges

Client, v1

Component, v1 Component, v2

Client, v2

Denker etal 2007

Page 60: Migration and Testing (EVO 2008)

Don’t jump.Walk with little tested steps