abapcoderetreat 23.7.2016 - tdd
TRANSCRIPT
![Page 1: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/1.jpg)
Deutschsprachige SAP® Anwendergruppe
Test Driven Development in ABAP
Christian Drumm, FACTUR Billing Solutions GmbHThomas Fiedler, SAP SE
![Page 2: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/2.jpg)
Agile Software Development
Agile principles
Agile processes
Agile methods
Re-factoring Scrum
Continuous
Integration
XP…
Kanban
Pair pro-gramming
Unit Tests
Test driven
development
![Page 3: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/3.jpg)
3
Test Driven Development – Introduction
Approach1. Implement test2. Implement application logic3. Refactor
Advantages> Software architecture > Quality> Maintainability > Tests as documentation
Red
Green
Refactor
![Page 4: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/4.jpg)
4
Test Driven Development – Tools
ABAP Unit > xUnit implementation in ABAO
test_method1( )test_method2( )
> setup( ) test_method3( ) teardown( )test_method4( )test_methodN( )
Integrated into SE80 and ABAP in Eclipse> Execute tests on class and package level > Test coverage analysis
Integrated into ABAP Test Cockpit
![Page 5: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/5.jpg)
5
Test Driven Development – Examples
Data access and business logic mixed within one method.
![Page 6: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/6.jpg)
6
Test Driven Development – Examples
Simple unit test.
![Page 7: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/7.jpg)
7
Test Driven Development – Examples
Data access using a data access class and preparation for dependency injection.
Mock implementation of data access class.
![Page 8: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/8.jpg)
8
Test Driven Development in practice
Independent developments vs. extensions of the SAP standard > Usage in independent developments is straightforward > Usage to extend SAP standard sometimes very difficult (e.g. BAdIS)
Legacy code vs. new code > TDD only possible for new code > TDD for legacy code may require fundamental changes to software architecture
Possibility of TDD depends on the used frameworks / APIs > BOL layer in CRM is very suitable for TDD > TDD in the context of e.g. the business partner BAPIs is virtually impossible
![Page 9: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/9.jpg)
9
The biggest issue when writing Unit Tests
Unit Test Application Code
Dependent Components
Configuration
User Interface
Customizing
Database access
Remote Call
Unknown Functions
![Page 10: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/10.jpg)
10
The biggest issue when writing Unit Tests
Unit Test Application Code
Dependent Components
Configuration
User Interface
Customizing
Database access
Remote Call
Unknown Functions
Mocking
![Page 11: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/11.jpg)
11
Example: Currency Conversion
Conversion-rate
Application
Currency Converter
Unit Test Mock
![Page 12: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/12.jpg)
12
Code Example (Application Code)
„Dependency Injection“ to control dependencies between components
Decoupling via interfaces
![Page 13: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/13.jpg)
13
Code Example (Test Code)
![Page 14: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/14.jpg)
14
Code Example (Test Code with Mock)
SAP Test Double Framework
![Page 15: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/15.jpg)
15
What about Legacy Code ?
![Page 16: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/16.jpg)
16
Application Code Test Code
Code Example (Legacy Code)
![Page 17: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/17.jpg)
17
Application Code Test Code
Code Replacement via Test-SeamsLab preview
![Page 18: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/18.jpg)
18
References
Getting Started with ABAP Testing and Troubleshooting - http://scn.sap.com/docs/DOC-24152 Introdcution to the SAP Test Double Framework - http://scn.sap.com/docs/DOC-61154 ABAP in Eclipse SCN community - http://scn.sap.com/community/abap/eclipse
![Page 19: ABAPCodeRetreat 23.7.2016 - TDD](https://reader035.vdocuments.mx/reader035/viewer/2022070523/58ed05151a28ab166c8b4671/html5/thumbnails/19.jpg)
Die vorliegende Präsentation ist urheberrechtlich geschützt (Copyright). Alle Rechte liegen, soweit nicht ausdrücklich anders gekennzeichnet, bei der Deutschsprachigen SAP-Anwendergruppe e. V.. Jedwede unerlaubte Verwendung ist nicht gestattet. Dies gilt insbesondere für die Vervielfältigung, Verbreitung, Übersetzung oder die Verwendung in elektronischen Systemen / digitalen Medien.
Deutschsprachige SAP® Anwendergruppe e.V.Altrottstraße 34aD-69190 Walldorf
Tel.: +49-(0)6227-358 09-58Fax: +49-(0)6227-358 09-59E-Mail: [email protected]: www.dsag.de
DSAG in ÖsterreichTel.: +43-(0)1-310 13 76E-Mail: [email protected] Web: www.dsag.at
DSAG in der SchweizTel.: +41-(0)31-311 10 03E-Mail: [email protected]: www.dsag-ev.ch
© DSAG e.V.
Kontakt DSAG