abap unit and tdd

19
ABAP Unit and TDD Hendrik Neumann SAP Inside Track Hamburg 2013 Copyright © 2013 evivax IT Consulting GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Upload: hendrik-neumann

Post on 26-May-2015

745 views

Category:

Technology


3 download

DESCRIPTION

Introduction into Test Driven Development (TDD) with ABAP Unit. Presented at SAP Inside Track Hamburg (sitHH) 2013: http://wiki.sdn.sap.com/wiki/display/events/SAP+Inside+Track+Hamburg+2013

TRANSCRIPT

Page 1: ABAP Unit and TDD

ABAP Unit and TDD

Hendrik Neumann

SAP Inside Track Hamburg 2013

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 2: ABAP Unit and TDD

Agenda

Unit Testing & ABAP Unit

Test Driven Development (TDD)

Live Coding

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 3: ABAP Unit and TDD

Unit Testing

Unit Testing is a method by which

individual units of source code are tested

to determine if they are fit to use.

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 4: ABAP Unit and TDD

xUnit Framework

Provides an automated solution with no

need to write the same tests many times

and no need to remember what should be

the result of each test.

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 5: ABAP Unit and TDD

xUnit Framework

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

setup( ) test_method( ) teardown( )

assert_*( ) – methods

Page 6: ABAP Unit and TDD

xUnit Framework

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

setup( ) test_method( ) teardown( )

test_method( )

test_method( )

test_method( )

test_method( )

test_method( )

test_method( )

Page 7: ABAP Unit and TDD

ABAP Unit

SAP‘s xUnit implemenation

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 8: ABAP Unit and TDD

ABAP Unit

Local test classes for global dev. artifacts

In Reports, Function Modules and Classes

Not acitve on production systems

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 9: ABAP Unit and TDD

ABAP Unit

Tools integration:

ABAP Workbench

Code Inspector Integration

ABAP Unit Browser

ABAP Test Cockpit (ATC)

ABAP in Eclipse

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 10: ABAP Unit and TDD

Test Driven Development

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 11: ABAP Unit and TDD

Test Driven Development

Never

After you wrote your code

Before you write your code

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

When do you write your Unit Tests?

Test Driven Development

Page 12: ABAP Unit and TDD

Test Driven Development

Test 1st

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 13: ABAP Unit and TDD

Test Driven Development

Test Cycle:

red green refactor

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 14: ABAP Unit and TDD

TDD Cycle

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Write a test that expresses how you’ll

use the code and what you need it to do.

Page 15: ABAP Unit and TDD

TDD Cycle

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Write enough code to get the

test to pass, but no more.

Page 16: ABAP Unit and TDD

TDD Cycle

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Clean up the code to remove

redundancy and improve the design.

Page 17: ABAP Unit and TDD

TDD Cycle

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Page 18: ABAP Unit and TDD

Code Kata: Roman Numerals

Copyright © 2013 evivax IT Consulting GmbH

Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]

Rules:

• smaller number in front of a larger number subtraction

• all else addition

• put only one smaller number in front of a larger number

• ones, tens, hundreds and thousands are separate items

I The numeral one. II is two, III is three.

V The numeral 5. IV is 4, VI is 6, VII is 7, VIII is 8.

X The numeral 10. IX is 9, XI is 11, etc.

L The numeral 50. XL would be 40.

C The numeral 100. C is short for the Latin word Centum, but Century

is eaysier to remember ;-)

D The numeral 500.

M The numeral 1000.

Page 19: ABAP Unit and TDD

So Long, and Thanks for All the Fish

Any Qs?

Copyright © 2013 evivax IT Consulting

GmbH Goebelstraße 21 | 64293 Darmstadt | Fon: 06151 - 506420 | e-mail: [email protected]