TDD in the ABAP world - sitNL 2013 edition
-
Upload
hendrik-neumann -
Category
Technology
-
view
833 -
download
1
description
Transcript of TDD in the ABAP world - sitNL 2013 edition
![Page 1: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/1.jpg)
© 2013 evivax IT Consulting GmbH
TDD in the ABAP World Hendrik Neumann
#sitNL 2013
![Page 2: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/2.jpg)
Agenda
(1) Unit Testing & ABAP Unit
(2) Test Driven Development (TDD)
(3) Live Coding
![Page 3: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/3.jpg)
© 2013 evivax IT Consulting GmbH
Unit Testing & ABAP Unit
![Page 4: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/4.jpg)
Unit Testing
Definition
![Page 5: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/5.jpg)
Unit Testing
Unit Testing is a method by which
individual units of source code are
tested to determine if they are fit
to use.
![Page 6: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/6.jpg)
Unit Testing
Unit Testing is a method by which
individual units are e.g.ource code
fittMethods of t Function Modules
fit Function Groups
fiMoModule Pools Function
Functn Reports
Methods
Function Groups
![Page 7: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/7.jpg)
Unit Testing
aim:
Find bugs early
Write once, run often
Effective Tests must be automated
solution:
xUnit Frameworks
![Page 8: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/8.jpg)
xUnit Framework
Definition
![Page 9: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/9.jpg)
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.
![Page 10: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/10.jpg)
xUnit Framework
How does it work?
![Page 11: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/11.jpg)
xUnit Framework
setup()
Create object under test common to all tests.
![Page 12: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/12.jpg)
xUnit Framework
setup() test_method()
Clear up your mess..
Call object under test – e.g. a public method
with test data.
![Page 13: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/13.jpg)
xUnit Framework
setup() test_method()
assert_*()–methods
Verify output of object under test using xUnit‘s
assert methods
![Page 14: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/14.jpg)
xUnit Framework
setup() test_method() teardown()
Clear up your mess..
![Page 15: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/15.jpg)
xUnit Framework
setup() test_method() teardown() test_method()
test_method() test_method()
test_method() test_method()
test_method()
![Page 16: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/16.jpg)
© 2013 evivax IT Consulting GmbH
ABAP Unit
![Page 17: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/17.jpg)
ABAP Unit
SAP‘s xUnit implemenation
![Page 18: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/18.jpg)
ABAP Unit
Local test classes for global development artifacts
In Reports, Function Modules and Classes
Not acitve on production systems
![Page 19: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/19.jpg)
ABAP Unit
• Tools integration:
–ABAP Workbench
–Code Inspector Integration
–ABAP Unit Browser
–ABAP Test Cockpit (ATC)
–ABAP in Eclipse
![Page 20: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/20.jpg)
© 2013 evivax IT Consulting GmbH
Test Driven Development
![Page 21: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/21.jpg)
Test Driven Development
• Never
• After you wrote your code
• Before you write your code
When do you write your Unit Tests?
![Page 22: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/22.jpg)
Test Driven Development
• Never
• After you wrote your code
• Before you write your code
When do you write your Unit Tests?
Test Driven Development
![Page 23: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/23.jpg)
Test Driven Development
Test 1st
![Page 24: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/24.jpg)
Test Cycle
Test Write a test that expresses how you’ll
use the code and what you need it to do.
![Page 25: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/25.jpg)
Test Cycle
Write enough code to get the test to pass,
but no more.
Code
Test
![Page 26: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/26.jpg)
Test Cycle
Code
Test
Refactor Clean up the code to remove redundancy and improve the design.
![Page 27: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/27.jpg)
Test Cycle
Code
Test
Refactor
![Page 28: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/28.jpg)
Test Cycle
Code Test
Refactor
![Page 29: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/29.jpg)
Test Cycle
Code
Test Refactor
![Page 30: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/30.jpg)
Test Cycle
Code
Test
Refactor
![Page 31: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/31.jpg)
Code Kata: Roman Numerals
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 32: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/32.jpg)
© 2013 evivax IT Consulting GmbH
So Long, and Thanks for All the Fish
Any Qs?
![Page 33: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/33.jpg)
© 2013 evivax IT Consulting GmbH
Green Bar Patterns
(hidden track)
![Page 34: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/34.jpg)
Green Bar Patterns
Fake it till you make it
• Start with hardcoded results and wait until tests force them to become real
![Page 35: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/35.jpg)
Green Bar Patterns
Triangulate To Abstraction
• Make the code abstract only when you have two or more examples
![Page 36: TDD in the ABAP world - sitNL 2013 edition](https://reader034.fdocuments.in/reader034/viewer/2022042700/555c22e1d8b42a0b418b4ad8/html5/thumbnails/36.jpg)
Green Bar Patterns
Obvious Implementation
• aka Don‘t be stupid
• If you really know the right way to implement it, do it that way