3. Test Driven Development – Introduction
Approach
1. Implement test
2. Implement application logic
3. Refactor
Advantages
> Software architecture
> Quality
> Maintainability
> Tests as documentation
3
Red
GreenRefactor
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
4
7. Test Driven Development – Examples
7
Data access using a data access
class and preparation for
dependency injection.
Mock implementation of data
access class.
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
8
9. The biggest issue when writing Unit Tests
9
Unit Test
Application
Code
Dependent
Components
Configuration
User Interface
Customizing
Database
access
Remote Call
Unknown
Functions
10. The biggest issue when writing Unit Tests
10
Unit Test
Application
Code
Dependent
Components
Configuration
User Interface
Customizing
Database
access
Remote Call
Unknown
Functions
Mocking
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
18
Softwarearchitektur
Seperation of Concerns (One Responsibility Principle); z.B. Trennung von Datenzugriff und Verarbeitungslogik Datenzugriffsklasse
KISS-Prinzip