SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
TDD – Test Driven Development
Hendrik Neumann
Agenda
(1) Unit Testing
(2) ABAP Unit
(3) Test Driven Development
Unit Testing
Unit Testing
Definition
Unit Testing
Unit Testing is a method by which
individual units of source code are
tested to determine if they are fit to
use.
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
Unit Testing
aim:
Find bugs early
Write once, run often
Effective Tests must be automated
solution:
xUnit Frameworks
xUnit Framework
xUnit Framework
Definition
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.
xUnit Framework
How does it work?
xUnit Framework
setup()
creates object under test
– used in all tests
xUnit Framework
setup()  test_method()
Clear up your
mess..
calls object under test
– e.g. a public method
with test data
xUnit Framework
setup()  test_method()
assert_*()–methods
verify the return value of
the object under test using
xUnit’s assert methods
xUnit Framework
setup()  test_method() teardown()
Clear up your
mess..
xUnit Framework
setup()  test_method() teardown()
test_method()
test_method()
test_method()
test_method()
test_method()
test_method()
ABAP Unit
ABAP Unit
SAP‘s xUnit implemenation
ABAP Unit
cl_abap_unit_assert=>assert_equals(
msg = 'Test msg'
act = act
exp = out->( )
).
assert_*()-Methods
ABAP Unit in ADT
ABAP Unit
Local test classes for global
development artifacts
In Reports, Function Modules and
Classes
Not acitve on production systems
ABAP Unit
• Tools integration:
–ABAP Workbench
–Code Inspector Integration
–ABAP Unit Browser
–ABAP Test Cockpit (ATC)
–ABAP in Eclipse
Test Driven Development
Test Driven Development
• Never
• After you wrote your code
• Before you write your code
When do you write your Unit Tests?
Test Driven Development
• Never
• After you wrote your code
• Before you write your code
When do you write your Unit Tests?
Test Driven Development
Test Driven Development
Test 1st
Test Cycle
Test
Write a test that expresses how you’ll use
the code and what you need it to do.
Test Cycle
Write enough code to get
the test to pass, but no
more.
Code
Test
Test Cycle
Code
Test
Refactor
Clean up the code to
remove redundancy and
improve the design.
Test Cycle
Code
Test
Refactor
Test Cycle
Code
Test
Refactor
Test Cycle
Code
Test
Refactor
Test Cycle
Code
Test
Refactor
Green Bar Patterns
Green Bar Patterns
Fake it till you make it
• Start with hardcoded results and wait
until tests force them to become real
Green Bar Patterns
Triangulate To Abstraction
• Make the code abstract only when you
have two or more examples
Green Bar Patterns
Obvious Implementation
• aka Don‘t be stupid
• If you really know the right way to
implement it, do it that way
Have FUN!
Backup
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.

Contenu connexe

Tendances

Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And Mocking
Joe Wilson
 
Software Testing Tecniques
Software Testing TecniquesSoftware Testing Tecniques
Software Testing Tecniques
ersanbilik
 

Tendances (19)

Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
 
Testing JavaScript Applications
Testing JavaScript ApplicationsTesting JavaScript Applications
Testing JavaScript Applications
 
Unit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqUnit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and Moq
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And Mocking
 
Unit testing
Unit testing Unit testing
Unit testing
 
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
 
03 test specification and execution
03   test specification and execution03   test specification and execution
03 test specification and execution
 
Simple Railroad Command Protocol
Simple Railroad Command ProtocolSimple Railroad Command Protocol
Simple Railroad Command Protocol
 
Test automation
Test automationTest automation
Test automation
 
Automation and Technical Debt
Automation and Technical DebtAutomation and Technical Debt
Automation and Technical Debt
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Software Testing Tecniques
Software Testing TecniquesSoftware Testing Tecniques
Software Testing Tecniques
 
Software Quality via Unit Testing
Software Quality via Unit TestingSoftware Quality via Unit Testing
Software Quality via Unit Testing
 
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
 
Performance Regression Analysis: Accomplishments and Challenges
Performance Regression Analysis: Accomplishments and ChallengesPerformance Regression Analysis: Accomplishments and Challenges
Performance Regression Analysis: Accomplishments and Challenges
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 

Similaire à ABAP Code Retreat Frankfurt 2016: TDD - Test Driven Development

Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
Meilan Ou
 

Similaire à ABAP Code Retreat Frankfurt 2016: TDD - Test Driven Development (20)

Unit Testing in R with Testthat - HRUG
Unit Testing in R with Testthat - HRUGUnit Testing in R with Testthat - HRUG
Unit Testing in R with Testthat - HRUG
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud Shaon
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Pair programming and introduction to TDD
Pair programming and introduction to TDDPair programming and introduction to TDD
Pair programming and introduction to TDD
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
Tdd
TddTdd
Tdd
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and Junit
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Unit testing with NUnit
Unit testing with NUnitUnit testing with NUnit
Unit testing with NUnit
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
TDD talk
TDD talkTDD talk
TDD talk
 

Plus de Hendrik Neumann (6)

SAP Stammtisch Frankfurt PLUS 11.10.2017 - introduction
SAP Stammtisch Frankfurt PLUS 11.10.2017 - introductionSAP Stammtisch Frankfurt PLUS 11.10.2017 - introduction
SAP Stammtisch Frankfurt PLUS 11.10.2017 - introduction
 
SAP Stammtisch Frankfurt 2017-10-11 - abapGit introduction
SAP Stammtisch Frankfurt 2017-10-11 - abapGit introductionSAP Stammtisch Frankfurt 2017-10-11 - abapGit introduction
SAP Stammtisch Frankfurt 2017-10-11 - abapGit introduction
 
What the git? - SAP Inside Track Munich 2016
What the git?  - SAP Inside Track Munich 2016What the git?  - SAP Inside Track Munich 2016
What the git? - SAP Inside Track Munich 2016
 
Fun with Mazes - sitNL 2015
Fun with Mazes - sitNL 2015 Fun with Mazes - sitNL 2015
Fun with Mazes - sitNL 2015
 
Fun with Mazes
Fun with MazesFun with Mazes
Fun with Mazes
 
ABAP Unit and TDD
ABAP Unit and TDDABAP Unit and TDD
ABAP Unit and TDD
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

ABAP Code Retreat Frankfurt 2016: TDD - Test Driven Development