+ All Categories
Home > Technology > Testing in Legacy: from Rags to Riches by Taras Slipets

Testing in Legacy: from Rags to Riches by Taras Slipets

Date post: 06-Jan-2017
Category:
Upload: javadayua
View: 183 times
Download: 1 times
Share this document with a friend
74
Testing in Legacy: From Rags to Riches
Transcript

Testing in Legacy: From Rags to Riches

2

I’d like to share our experience

3

About me

{ “First name”: “Taras”, “Last name”: “Slipets”, “E-mail”: “[email protected]”, “LinkedIn Profile”: “http://www.linkedin.com/ pub/taras-slipets/ 48/466/516”, “Interests”: [ “Software Engineering”, “Music”, “Skiing”, ]}

4

About presentation

5

About presentation

• General feeling about legacy

• System that we’ve received for improvement

• Effective steps that were performed

• What we’ve eventually reached

6

What does it mean – Legacy system?

7

Ask expert

8

Legacy system is…

9

Just long-term project

10

Where do we go now

• General feeling about legacy

• System that we’ve received for improvement

• Effective steps that were performed

• What we’ve eventually reached

11

What we’ve received

• 11-years old system SUCCESSFULLY running on production servers• Written in Java 1.4• No frameworks usage• No documentation• No developers who has worked on it• Impatient customers• Pantient management• other surprises…

12

Bus factor

13

What we’d like to have?

14

What we’d like to have?

Shiny system with all cutting-edge frameworks

Reduce pain of maintenance and support

15

What we’d like to have?

Shiny system with all cutting-edge frameworks

Reduce pain of maintenance and support

16

Where do we go now

• General feeling about legacy

• System that we’ve received for improvement

• Effective steps that were performed

• What we’ve eventually reached

17

So, how we did it?

18

Setup your environmentLet’s deployour changes!

Great! Wheredo we go?

Directly to production!

“To production!”he said…

19

Setup your environment

DEV STAGE PROD

20

21

Logs, logs, logs

22

Domain model – classes level

23

Domain model – database level

24

Domain model – workflows

25

Peer review VERY often

26

Before changing code

27

We need to ensure it works

28

Testing

29

Testing levels

Unit testsIntegration testsSystem tests

30

Test existing and expected behavior

31

System testing (feature testing)

Application under testingSystem tests

Process Process

32

External world communication

33

External world communication - mocks

34

External world communication - mocks

35

External world communication - mocks

36

External world communication - mocks

37

System tests automation

38

Finally – let’s touch code!

39

Top occurring issues

• “do-stuff” methods• “I’m aware of everything” classes• “Celebrities” classes/interfaces• “Magic goes here” blocks without comments• Just obsolete code

40

What to do?

41

How about

42

43

Refactoring facilities• Extract method• Extract interface• Parameter object• Method object• Replace type-checking code with

State/Strategy• Move method/field• …

44

Unit tests jumps into

45

Frameworks

• EasyMock

• Mockito

• PowerMock

46

IndicationAfter initial tests are written, use PowerMock as indicator of bad system design

47

What is next?

48

49

50

Most used in our case

• Template method• Strategy• State• Visitor• Command• Chain of Responsibility• Observer

51

And again - logs, logs, logs

52

Hey, where are new features?

53

Extend functionality AFA it’s possible

54

How deep refactoring should be?

55

Theory the Godmother

• S.O.L.I.D.

• D.R.Y.

• K.I.S.S.

• …

56

In real world

57

Now we can add integration tests

58

What about build/deployment time?

59

What about build/deployment time?

60

Simple rule

61

But for us it hurt

62

Remedy?

63

Remedy

• Make app self-contained

• Simplify manual installation

64

Operations are happy

65

If it steal hurts - automate deployment

66

Where do we go now

• General feeling about legacy

• System that we’ve received for improvement

• Effective steps that were performed

• What we’ve eventually reached

67

Complete features list + tests for them

68

The winner takes it all

69

The dreams come true - build-pipeline!

70

A-team!

71

Lessons learned

72

Lessons learned

• Old project is not a disaster, but challenge• Start from environment setup and feature testing. At least to

some extent• Share knowledge with your colleagues and write docs• Do not underestimate power of classical remedies (patterns,

working techniques)• Be agile ;)

74

Thanks for your attention!


Recommended