test driven development @ volvo - chalmerstest driven development – benefits (continued) • all...

20
AB Volvo 1 2012-11-15 IT Governance, Enterprise Architecture Team, Åke Liljenberg Test Driven Development @ Volvo - why it is important for us Åke Liljenberg Enterprise Architecture Team Corporate Process & IT [email protected]

Upload: others

Post on 12-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 1 2012-11-15 IT Governance, Enterprise Architecture Team, Åke Liljenberg

Test Driven Development @ Volvo - why it is important for us

Åke Liljenberg Enterprise Architecture Team Corporate Process & IT [email protected]

Page 2: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 2 2012-11-15 Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

CEO Office Coordinator Pär Östberg

CEO OFFICE COORDINATION

Group Trucks Sales &

Marketing Americas Dennis Slagle

GROUP TRUCKS

Executive Assistant Susanne Thelander

Finance & Business Support

Anders Osberg

Volvo Trucks Claes Nilsson

Renault Trucks Heinz-Jürgen Loew

Group Trucks Operations

Mikael Bratt

Chief Executive Officer Olof Persson

Group Trucks Sales &

Marketing EMEA Peter

Karlsten

Corporate Human Resources Kerstin Renard

Corporate Public & Environmental Affairs

Jan-Eric Sundgren

Corporate Communication Per Löjdquist

Corporate Strategy Karin Falk

Corporate Legal & Compliance

Eva Persson

Corporate Process & IT Magnus Carlander

Group Trucks Sales &

Marketing APAC

Joachim Rosenberg

Volvo Penta Björn Ingemanson

Volvo Aero Staffan Zachrisson

Buses Per Carlsson

Construction Equipment

Pat Olney

Governmental Sales Stefano Chmielewski

Volvo Financial Services Martin Weissburg

Truck Joint Ventures * Pär Östberg

Business Areas **

Håkan Karlsson

Group Trucks Technology

Torbjörn Holmström

Here is the Enterprise Architecture Team

Page 3: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo

New FH series heavy truck

3 2012-11-15

A completely new electrical system architecture

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 4: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo

Off-board (back-end)

On-board (in the truck)

Many changes in parallel…

4 2012-11-15

New electrical

architecture spec�s

Suppliers� delivery

New ECU HW & SW

Embedded Software

Tools update

Central systems update

?

•  ~25 ECU�s – new HW & SW •  Multiple suppliers

•  Multiple software projects

•  New information model •  Major updates in central

systems

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

•  Fixed date!

Page 5: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo

To our rescue...

Test Driven Development ! (or at least a pre-requisite for success)

5 2012-11-15 Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 6: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 6 2012-11-15

XP’s 12 Development Practices:

•  Fine scale feedback –  Pair programming –  Planning Game –  Test Driven Development –  Whole team

•  Continuous process –  Continuous Integration –  Refactoring or Design Improvement –  Small Releases

•  Shared understanding –  Coding Standards –  Collective Code Ownership –  Simple Design/DDD –  System Metaphor

•  Programmer welfare –  Sustainable pace

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 7: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 7 2012-11-15

1.  Add a test 2.  Run all tests and see

the new one fail

3. Write some code 4. Run the automated tests and see them succeed

5. Refactor code - Repeat ! -

The "Test-Driven Development Mantra�:

Red / Green / Refactor

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

- Tests - Clean Code

Page 8: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 8 2012-11-15

Test Driven Development

KISS - "Keep It Simple, Stupid"

And

YAGNI - "You Ain't Gonna Need It"

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Write only the code necessary to pass tests

- Makes the design cleaner and clearer

Take small steps when required

Page 9: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 9 2012-11-15

Test Driven Development - Benefits

• Improves quality • Programmers that write more tests tends to be

more productive • Programmers only rarely feel the need to

invoke a debugger • Drives the design of a program

– The programmer is only concerned with the interface and not the implementation

– Leads to more modularized, flexible, and extensible code

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 10: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 10 2012-11-15

Test Driven Development – Benefits (continued)

• All (or most) written code is covered by a test – Gives the programmer, and subsequent

users, a greater level of trust in the code • Eliminating defects early in the process

usually avoids lengthy and tedious debugging later in the project

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 11: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 11 2012-11-15

Refactoring or Design Improvement

•  Integral part of the software development cycle •  Taking out complex design

•  Constantly taking out “smelly” or “dead” code

ISBN 0201485672

Relying on tests, not losing/changing functionality!

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 12: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 12 2012-11-15

Simplicity

•  Take the �simple is best� approach •  Use refactoring to make complex code simpler

Relying on tests, not losing/changing functionality!

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 13: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 13 2012-11-15

Refactoring

Person

- name

+ getTelephoneNumber()

TelephoneNumber

- areaCode- number

+ getTelephoneNumber()

1

Person

- name- areaCode- number

+ getTelephoneNumber()

Example: A class (TelephoneNumber) isn't doing very much. Move all its features into another class and delete it.

Relying on tests, not losing/changing functionality!

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 14: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 14 2012-11-15

Continuous Integration

Aims to: •  improve the quality of software

•  reduce the time taken to deliver it

What it is: “continuous processes of applying quality control

- small pieces of effort, applied frequently“ - Wikipedia

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 15: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 15 2012-11-15

Continuous Integration “best” practices

•  Maintain a code repository •  Automate the build

•  Make the build self-testing

•  Everyone commits (at least) every day

•  Every commit should be built

•  Test in a clone of the production environment

•  Make it easy to get the latest deliverables

•  Everyone can see the results of the latest build

•  Automate deployment

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 16: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 16 2012-11-15

Continuous Integration - benefits

• When unit tests fail or a bug emerges, developers might revert the codebase back to a bug-free state, without wasting time debugging

• Developers detect and fix integration problems continuously - avoiding last-minute chaos at release dates, (when everyone tries to check in their slightly incompatible versions).

• Early warning of broken/incompatible code • Early warning of conflicting changes

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 17: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 17 2012-11-15

Continuous Integration – benefits (continued)

• Immediate unit testing of all changes • Constant availability of a "current" build for

testing, demo, or release purposes • Immediate feedback to developers on the

quality, functionality, or system-wide impact of code they are writing

• Frequent code check-in pushes developers to create modular, less complex code

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 18: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 18 2012-11-15

Continuous Integration – a few disadvantages

•  Initial setup time required • Hardware costs for build machines

The advantages well outweigh the disadvantages!

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 19: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo

TDD – an enabler for successful projects

19 2012-11-15

An absolute nessecity for handling the complexity!

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg

Page 20: Test Driven Development @ Volvo - ChalmersTest Driven Development – Benefits (continued) • All (or most) written code is covered by a test – Gives the programmer, and subsequent

AB Volvo 20 2012-11-15

Thanks! Questions?

Corporate Process & IT, Enterprise Architecture Team, Åke Liljenberg