SlideShare a Scribd company logo
1 of 14
Download to read offline
© Kaufland 2016 |
ABAP CODERETREAT WEINSBERG
Unit Testing
KIS, Weinsberg, 23.07.2016
ABAP CodeRetreat Weinsberg121.07.2016
© Kaufland 2016 |
WHO WE ARE
KAUFLAND
We are more than just a successful international trading company:
We are a company where many colleagues become a team, jobs
are safe workplaces and real satisfaction
Diversity and stability
We offer a wide range of jobs with many different entry-levels and
career opportunities. Our company is continuously growing, that
makes us self-confident
Openness and friendly cooperation
We support a cooperation based on friendliness and mutual trust
ABAP CodeRetreat Weinsberg221.07.2016
© Kaufland 2016 |
WHERE WE ARE
KAUFLAND
Expansive growth, economic size
• We are successfully expanding in Germany, Poland, Czech
Republic, Slovakia, Croatia, Romania and Bulgaria
• Over 150,500 employees form our strong Kaufland team in
Europe
International cooperation and prospects
• We offer an international work environment
• We provide a wide variety of tasks in collaboration with our
international colleagues
• According to the area of deployment you will have the
opportunity to collect experience abroad, in one of our
European locations
ABAP CodeRetreat Weinsberg321.07.2016
© Kaufland 2016 | ABAP CodeRetreat Weinsberg4
KAUFLAND INFORMATION SYSTEMS
We are the IT service provider for Kaufland. Ensuring high
business performance and carrying data streams on the right track
is our daily responsibility
Keep IT simple and safe
Our objectives are to comprehensively advice our business
departments in designing their business processes and to
implement software solutions
OUR IT IN FIGURES
21.07.2016
220
SAP
Systems
40
SAP
Developers
25k Z Reports
© Kaufland 2016 |
UNIT TESTING
ABAP CodeRetreat Weinsberg521.07.2016
Unit Testing
Integration Testing
System Testing
Acceptance Testing
© Kaufland 2016 | ABAP CodeRetreat Weinsberg6
• Set up an initial state
• Confront the method under test with test values
• Compare actual value with expected test value
• Implemented in form of test methods
• Test methods are hosted in a test class
• Test classes are local classes to the program object under test
• Use global test classes only to host reusable logic for tests
• Comparisons are done with class CL_ABAP_UNIT_ASSERT
UNIT TESTS ABAP UNIT TESTS
CREATING ABAP UNIT TESTS
UNIT TESTING
21.07.2016
© Kaufland 2016 |
• Test classes are local classes defined with the FOR TESTING addition
• Test methods are (private) parameterless instance methods, also declared with the FOR TESTING
addition
• Use Fixtures to ensure particular starting conditions
• [class] setup and [class] teardown
TEST CLASSES AND TEST METHODS
ABAP CodeRetreat Weinsberg7
UNIT TESTING
21.07.2016
setup( ).
teardown( ).
my_first_test_method( ).
© Kaufland 2016 |
EXAMPLE
ABAP CodeRetreat Weinsberg8
UNIT TESTING
21.07.2016
© Kaufland 2016 |
• Testing starts already during the design of your application
• The following slides show some pitfalls you should keep in mind
• All coding samples are more or less pseudo-code in ABAP style
PREPARATION
ABAP CodeRetreat Weinsberg9
UNIT TESTING
21.07.2016
© Kaufland 2016 | ABAP CodeRetreat Weinsberg10
PITFALL #1
CLASS car.
PRIVATE SECTION.
DATA g_fuel TYPE i.
PUBLIC SECTION.
set_fuel IMPORTING i_fuel TYPE i.
has_fuel RETURNING r_has_fuel TYPE xfeld.
ENDCLASS.
CLASS testcar FOR TESTING.
PRIVATE SECTION.
DATA g_testobject TYPE REF TO car.
METHOD class_setup.
g_testobject = NEW #( ).
METHOD test_fuel.
g_testobject->set_fuel( 30 ).
METHOD test_has_fuel.
DATA(has_fuel) = g_test_object->has_fuel( ).
ENDCLASS.
UNIT TESTING
21.07.2016
• Test cases guarantee no order!
• When method test_has_fuel() is called
we do not know in which state the test-
object already is!
• Take care to initialize your test-object before
each testcase so that you know the current
state! (e.g. use setup() instead of
class_setup())
Each testmethod has to return the same
result each time it's called otherwise we cannot
test it.
© Kaufland 2016 | ABAP CodeRetreat Weinsberg11
PITFALL #2
CLASS order.
DATA g_order_number TYPE i.
METHOD get_positions.
" load data
SELECT * FROM mseg
WHERE mblnr = g_order_number.
" prepare data
" do something else
" return result.
ENDCLASS.
UNIT TESTING
21.07.2016
• We do not know what is currently in the
database!
• We do not know which data will be
prepared!
• We cannot assume what data will be
returned!
Do not load information from sources that
cannot be controlled during testing. Load
data before instantiating the order object.
This will enable us to write a testmethod for
the data preparation.
Alternative solution: use a database-
handler-class and pass it as a parameter.
During testing you can use a mock of the
database-handler that returns fix results.
© Kaufland 2016 | ABAP CodeRetreat Weinsberg12
PITFALL #3
CLASS store.
METHOD is_opened.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = sy-datum
IMPORTING
day = day.
IF day <> 7.
r_is_opened = abap_true.
ENDIF.
ENDCLASS.
UNIT TESTING
21.07.2016
• If we expect the store to be closed the
testmethod will only succeed on sundays
• Testmethods expect a hard-coded result. Not
possible in this case!
Don't use system (or other) variables that you
cannot control. Better give the date as parameter.
So your testmethod can call
testobject->is_opened( '20160505' ).
© Kaufland 2016 | ABAP CodeRetreat Weinsberg13
UNIT TESTING
21.07.2016
POSSIBLE ARCHITECTURE
Database
Database
provider
Business
object
Data Access
Object (DAO)
Database layer Business layerAccess layer
© Kaufland 2016 |
• Sample Reports in package: SABP_UNIT_SAMPLE
• Executing Tests: Ctrl + Shift + F10
• Verification of test expectations: CL_ABAP_UNIT_ASSERT
• Test classes and methods are defined / declared with the FOR TESTING addition
• Considerations on how to write testable code must be included in the design avoid the pitfalls
HOW TO GET STARTED / KEY TAKEAWAYS
ABAP CodeRetreat Weinsberg14
UNIT TESTING
21.07.2016

More Related Content

What's hot

Building reliable applications with React, C#, and Azure
Building reliable applications with React, C#, and AzureBuilding reliable applications with React, C#, and Azure
Building reliable applications with React, C#, and AzureMaurice De Beijer [MVP]
 
Building large and scalable mission critical applications with React
Building large and scalable mission critical applications with ReactBuilding large and scalable mission critical applications with React
Building large and scalable mission critical applications with ReactMaurice De Beijer [MVP]
 
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...Sauce Labs
 
Test Armada Sauce Labs
Test Armada Sauce LabsTest Armada Sauce Labs
Test Armada Sauce LabsTest Armada
 
Introduction to Gauge
Introduction to GaugeIntroduction to Gauge
Introduction to Gaugevodqancr
 
Qa workshop
Qa workshopQa workshop
Qa workshopJohn Doe
 
Building a culture of quality at scale
Building a culture of quality at scaleBuilding a culture of quality at scale
Building a culture of quality at scaleTest Armada
 
Final Automation Testing
Final Automation TestingFinal Automation Testing
Final Automation Testingpriya_trivedi
 
Execute Automation Testing in 3 Steps
Execute Automation Testing in 3 StepsExecute Automation Testing in 3 Steps
Execute Automation Testing in 3 StepsExecuteAutomation
 
Testing OSGi-based Applications with DA-Testing
Testing OSGi-based Applications with DA-TestingTesting OSGi-based Applications with DA-Testing
Testing OSGi-based Applications with DA-TestingValery Abu-Eid
 
Test & Dynamics CRM - extremeCRM Berlin 2012
Test & Dynamics CRM - extremeCRM Berlin 2012Test & Dynamics CRM - extremeCRM Berlin 2012
Test & Dynamics CRM - extremeCRM Berlin 2012Wael Hamze
 
Automation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDDAutomation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDDRapidValue
 
ATAGTR2017 Keeping pace with Product Evolution: UI Automation Framework Guide...
ATAGTR2017 Keeping pace with Product Evolution: UI Automation Framework Guide...ATAGTR2017 Keeping pace with Product Evolution: UI Automation Framework Guide...
ATAGTR2017 Keeping pace with Product Evolution: UI Automation Framework Guide...Agile Testing Alliance
 
Qa process 2012
Qa process 2012Qa process 2012
Qa process 2012ashokack
 
Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces
Episode 3 – Classes, Inheritance, Abstract Class, and InterfacesEpisode 3 – Classes, Inheritance, Abstract Class, and Interfaces
Episode 3 – Classes, Inheritance, Abstract Class, and InterfacesJitendra Zaa
 

What's hot (19)

Building reliable applications with React, C#, and Azure
Building reliable applications with React, C#, and AzureBuilding reliable applications with React, C#, and Azure
Building reliable applications with React, C#, and Azure
 
Building large and scalable mission critical applications with React
Building large and scalable mission critical applications with ReactBuilding large and scalable mission critical applications with React
Building large and scalable mission critical applications with React
 
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
 
Test Armada Sauce Labs
Test Armada Sauce LabsTest Armada Sauce Labs
Test Armada Sauce Labs
 
Introduction to Gauge
Introduction to GaugeIntroduction to Gauge
Introduction to Gauge
 
I am hooked on React
I am hooked on ReactI am hooked on React
I am hooked on React
 
Qa workshop
Qa workshopQa workshop
Qa workshop
 
Building a culture of quality at scale
Building a culture of quality at scaleBuilding a culture of quality at scale
Building a culture of quality at scale
 
Final Automation Testing
Final Automation TestingFinal Automation Testing
Final Automation Testing
 
Execute Automation Testing in 3 Steps
Execute Automation Testing in 3 StepsExecute Automation Testing in 3 Steps
Execute Automation Testing in 3 Steps
 
Testing OSGi-based Applications with DA-Testing
Testing OSGi-based Applications with DA-TestingTesting OSGi-based Applications with DA-Testing
Testing OSGi-based Applications with DA-Testing
 
Feature toggles
Feature togglesFeature toggles
Feature toggles
 
Test & Dynamics CRM - extremeCRM Berlin 2012
Test & Dynamics CRM - extremeCRM Berlin 2012Test & Dynamics CRM - extremeCRM Berlin 2012
Test & Dynamics CRM - extremeCRM Berlin 2012
 
Automation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDDAutomation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDD
 
ATAGTR2017 Keeping pace with Product Evolution: UI Automation Framework Guide...
ATAGTR2017 Keeping pace with Product Evolution: UI Automation Framework Guide...ATAGTR2017 Keeping pace with Product Evolution: UI Automation Framework Guide...
ATAGTR2017 Keeping pace with Product Evolution: UI Automation Framework Guide...
 
Qa process 2012
Qa process 2012Qa process 2012
Qa process 2012
 
Automation With A Tool Demo
Automation With A Tool DemoAutomation With A Tool Demo
Automation With A Tool Demo
 
Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces
Episode 3 – Classes, Inheritance, Abstract Class, and InterfacesEpisode 3 – Classes, Inheritance, Abstract Class, and Interfaces
Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces
 
Web tech: lecture 5
Web tech: lecture 5Web tech: lecture 5
Web tech: lecture 5
 

Viewers also liked

ABAPCodeRetreat 23.7.2016 - TDD
ABAPCodeRetreat 23.7.2016 - TDDABAPCodeRetreat 23.7.2016 - TDD
ABAPCodeRetreat 23.7.2016 - TDDABAPCodeRetreat
 
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAPABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAPABAPCodeRetreat
 
ABAPCodeRetreat - ABAP PUSH CHANNELS and SAP FIORI
ABAPCodeRetreat -   ABAP PUSH CHANNELS and SAP FIORIABAPCodeRetreat -   ABAP PUSH CHANNELS and SAP FIORI
ABAPCodeRetreat - ABAP PUSH CHANNELS and SAP FIORIABAPCodeRetreat
 
TDD in the ABAP world - sitNL 2013 edition
TDD in the ABAP world - sitNL 2013 editionTDD in the ABAP world - sitNL 2013 edition
TDD in the ABAP world - sitNL 2013 editionHendrik Neumann
 
Case Study: Automated Code Reviews In A Grown SAP Application Landscape At EW...
Case Study: Automated Code Reviews In A Grown SAP Application Landscape At EW...Case Study: Automated Code Reviews In A Grown SAP Application Landscape At EW...
Case Study: Automated Code Reviews In A Grown SAP Application Landscape At EW...Virtual Forge
 
SAP Inside Track Lima 09 - Keynote
SAP Inside Track Lima 09 - KeynoteSAP Inside Track Lima 09 - Keynote
SAP Inside Track Lima 09 - KeynoteAlvaro Tejada
 
Happy sap hana friends
Happy sap hana friendsHappy sap hana friends
Happy sap hana friendsAlvaro Tejada
 
SAP Inside Track Lima 09 - Ruby y SAP
SAP Inside Track Lima 09 - Ruby y SAPSAP Inside Track Lima 09 - Ruby y SAP
SAP Inside Track Lima 09 - Ruby y SAPAlvaro Tejada
 
SmallWorlds - BoF Las Vegas TechEd 2008
SmallWorlds - BoF Las Vegas TechEd 2008SmallWorlds - BoF Las Vegas TechEd 2008
SmallWorlds - BoF Las Vegas TechEd 2008Alvaro Tejada
 
The best debugging tool - your brain
The best debugging tool - your brainThe best debugging tool - your brain
The best debugging tool - your brainChristian Drumm
 

Viewers also liked (12)

ABAPCodeRetreat 23.7.2016 - TDD
ABAPCodeRetreat 23.7.2016 - TDDABAPCodeRetreat 23.7.2016 - TDD
ABAPCodeRetreat 23.7.2016 - TDD
 
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAPABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
 
ABAPCodeRetreat - ABAP PUSH CHANNELS and SAP FIORI
ABAPCodeRetreat -   ABAP PUSH CHANNELS and SAP FIORIABAPCodeRetreat -   ABAP PUSH CHANNELS and SAP FIORI
ABAPCodeRetreat - ABAP PUSH CHANNELS and SAP FIORI
 
TDD in the ABAP world - sitNL 2013 edition
TDD in the ABAP world - sitNL 2013 editionTDD in the ABAP world - sitNL 2013 edition
TDD in the ABAP world - sitNL 2013 edition
 
Case Study: Automated Code Reviews In A Grown SAP Application Landscape At EW...
Case Study: Automated Code Reviews In A Grown SAP Application Landscape At EW...Case Study: Automated Code Reviews In A Grown SAP Application Landscape At EW...
Case Study: Automated Code Reviews In A Grown SAP Application Landscape At EW...
 
SAP Inside Track Lima 09 - Keynote
SAP Inside Track Lima 09 - KeynoteSAP Inside Track Lima 09 - Keynote
SAP Inside Track Lima 09 - Keynote
 
Happy sap hana friends
Happy sap hana friendsHappy sap hana friends
Happy sap hana friends
 
SAP Inside Track Lima 09 - Ruby y SAP
SAP Inside Track Lima 09 - Ruby y SAPSAP Inside Track Lima 09 - Ruby y SAP
SAP Inside Track Lima 09 - Ruby y SAP
 
SmallWorlds - BoF Las Vegas TechEd 2008
SmallWorlds - BoF Las Vegas TechEd 2008SmallWorlds - BoF Las Vegas TechEd 2008
SmallWorlds - BoF Las Vegas TechEd 2008
 
ABAP Unit and TDD
ABAP Unit and TDDABAP Unit and TDD
ABAP Unit and TDD
 
The best debugging tool - your brain
The best debugging tool - your brainThe best debugging tool - your brain
The best debugging tool - your brain
 
1H2007 Results Full
1H2007 Results Full1H2007 Results Full
1H2007 Results Full
 

Similar to ABAPCodeRetreat 23.7.2016 - Unit Testing

Expert sizing &amp; methods of sizing validation
Expert sizing &amp; methods of sizing validationExpert sizing &amp; methods of sizing validation
Expert sizing &amp; methods of sizing validationJaleel Ahmed Gulammohiddin
 
CV Gabor Vigh
CV Gabor VighCV Gabor Vigh
CV Gabor VighG Vigh
 
DOES16 London - Darren Hague - SAP’s DevOps Journey: From Building an App to ...
DOES16 London - Darren Hague - SAP’s DevOps Journey: From Building an App to ...DOES16 London - Darren Hague - SAP’s DevOps Journey: From Building an App to ...
DOES16 London - Darren Hague - SAP’s DevOps Journey: From Building an App to ...Gene Kim
 
Perf tuning with-multitenant
Perf tuning with-multitenantPerf tuning with-multitenant
Perf tuning with-multitenantJacques Kostic
 
MEASURE project : Measuring Software Engineering, OW2con'18, June 7-8, 2018, ...
MEASURE project : Measuring Software Engineering, OW2con'18, June 7-8, 2018, ...MEASURE project : Measuring Software Engineering, OW2con'18, June 7-8, 2018, ...
MEASURE project : Measuring Software Engineering, OW2con'18, June 7-8, 2018, ...OW2
 
10 ошибок в работе с аналитикой / Вера Карпова (devtodev)
10 ошибок в работе с аналитикой / Вера Карпова (devtodev)10 ошибок в работе с аналитикой / Вера Карпова (devtodev)
10 ошибок в работе с аналитикой / Вера Карпова (devtodev)DevGAMM Conference
 
Clad exam preparation_guide_using_lab_view_nxg
Clad exam preparation_guide_using_lab_view_nxgClad exam preparation_guide_using_lab_view_nxg
Clad exam preparation_guide_using_lab_view_nxgR.VINOTHKUMAR Enginevinoth
 
Westrich spock-assets-gum
Westrich spock-assets-gumWestrich spock-assets-gum
Westrich spock-assets-gumBrian Westrich
 
Behaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlowBehaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlowPascal Laurin
 
Automating sap testing with qtp10 & qc10
Automating sap testing with qtp10 & qc10Automating sap testing with qtp10 & qc10
Automating sap testing with qtp10 & qc10Patrick Sun
 
Optimizely NYC Developer Meetup - Experimentation at Blue Apron
Optimizely NYC Developer Meetup - Experimentation at Blue ApronOptimizely NYC Developer Meetup - Experimentation at Blue Apron
Optimizely NYC Developer Meetup - Experimentation at Blue ApronOptimizely
 
Meetup TestingUy 2017: Automating the Viewer: a cross-functional team approach
Meetup TestingUy 2017: Automating the Viewer: a cross-functional team approachMeetup TestingUy 2017: Automating the Viewer: a cross-functional team approach
Meetup TestingUy 2017: Automating the Viewer: a cross-functional team approachClaudia Badell
 
Meetup TestingUy 2017 - Automating the Viewer: a cross-functional team approach
Meetup TestingUy 2017 - Automating the Viewer: a cross-functional team approachMeetup TestingUy 2017 - Automating the Viewer: a cross-functional team approach
Meetup TestingUy 2017 - Automating the Viewer: a cross-functional team approachTestingUy
 
Fossil Benchmarking Analysis
Fossil Benchmarking AnalysisFossil Benchmarking Analysis
Fossil Benchmarking AnalysisScottMadden, Inc.
 
Six sigma on burning brownie
Six sigma on burning brownieSix sigma on burning brownie
Six sigma on burning brownieYamna Rashid
 
Quick Test Professional (QTP/UFT)
Quick Test Professional (QTP/UFT)Quick Test Professional (QTP/UFT)
Quick Test Professional (QTP/UFT)Rajathi-QA
 
how to implement agile | 12 principles of agile
how to implement agile | 12 principles of agilehow to implement agile | 12 principles of agile
how to implement agile | 12 principles of agileAnjaliNair289117
 
CV_AUTOMATION_TEST_ENGINEER
CV_AUTOMATION_TEST_ENGINEERCV_AUTOMATION_TEST_ENGINEER
CV_AUTOMATION_TEST_ENGINEERPERLA RAVI THEJA
 

Similar to ABAPCodeRetreat 23.7.2016 - Unit Testing (20)

Expert sizing &amp; methods of sizing validation
Expert sizing &amp; methods of sizing validationExpert sizing &amp; methods of sizing validation
Expert sizing &amp; methods of sizing validation
 
CV Gabor Vigh
CV Gabor VighCV Gabor Vigh
CV Gabor Vigh
 
DOES16 London - Darren Hague - SAP’s DevOps Journey: From Building an App to ...
DOES16 London - Darren Hague - SAP’s DevOps Journey: From Building an App to ...DOES16 London - Darren Hague - SAP’s DevOps Journey: From Building an App to ...
DOES16 London - Darren Hague - SAP’s DevOps Journey: From Building an App to ...
 
Perf tuning with-multitenant
Perf tuning with-multitenantPerf tuning with-multitenant
Perf tuning with-multitenant
 
MEASURE project : Measuring Software Engineering, OW2con'18, June 7-8, 2018, ...
MEASURE project : Measuring Software Engineering, OW2con'18, June 7-8, 2018, ...MEASURE project : Measuring Software Engineering, OW2con'18, June 7-8, 2018, ...
MEASURE project : Measuring Software Engineering, OW2con'18, June 7-8, 2018, ...
 
Code vigil
Code vigilCode vigil
Code vigil
 
Measure project ow2-2018
Measure project   ow2-2018Measure project   ow2-2018
Measure project ow2-2018
 
10 ошибок в работе с аналитикой / Вера Карпова (devtodev)
10 ошибок в работе с аналитикой / Вера Карпова (devtodev)10 ошибок в работе с аналитикой / Вера Карпова (devtodev)
10 ошибок в работе с аналитикой / Вера Карпова (devtodev)
 
Clad exam preparation_guide_using_lab_view_nxg
Clad exam preparation_guide_using_lab_view_nxgClad exam preparation_guide_using_lab_view_nxg
Clad exam preparation_guide_using_lab_view_nxg
 
Westrich spock-assets-gum
Westrich spock-assets-gumWestrich spock-assets-gum
Westrich spock-assets-gum
 
Behaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlowBehaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlow
 
Automating sap testing with qtp10 & qc10
Automating sap testing with qtp10 & qc10Automating sap testing with qtp10 & qc10
Automating sap testing with qtp10 & qc10
 
Optimizely NYC Developer Meetup - Experimentation at Blue Apron
Optimizely NYC Developer Meetup - Experimentation at Blue ApronOptimizely NYC Developer Meetup - Experimentation at Blue Apron
Optimizely NYC Developer Meetup - Experimentation at Blue Apron
 
Meetup TestingUy 2017: Automating the Viewer: a cross-functional team approach
Meetup TestingUy 2017: Automating the Viewer: a cross-functional team approachMeetup TestingUy 2017: Automating the Viewer: a cross-functional team approach
Meetup TestingUy 2017: Automating the Viewer: a cross-functional team approach
 
Meetup TestingUy 2017 - Automating the Viewer: a cross-functional team approach
Meetup TestingUy 2017 - Automating the Viewer: a cross-functional team approachMeetup TestingUy 2017 - Automating the Viewer: a cross-functional team approach
Meetup TestingUy 2017 - Automating the Viewer: a cross-functional team approach
 
Fossil Benchmarking Analysis
Fossil Benchmarking AnalysisFossil Benchmarking Analysis
Fossil Benchmarking Analysis
 
Six sigma on burning brownie
Six sigma on burning brownieSix sigma on burning brownie
Six sigma on burning brownie
 
Quick Test Professional (QTP/UFT)
Quick Test Professional (QTP/UFT)Quick Test Professional (QTP/UFT)
Quick Test Professional (QTP/UFT)
 
how to implement agile | 12 principles of agile
how to implement agile | 12 principles of agilehow to implement agile | 12 principles of agile
how to implement agile | 12 principles of agile
 
CV_AUTOMATION_TEST_ENGINEER
CV_AUTOMATION_TEST_ENGINEERCV_AUTOMATION_TEST_ENGINEER
CV_AUTOMATION_TEST_ENGINEER
 

Recently uploaded

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

ABAPCodeRetreat 23.7.2016 - Unit Testing

  • 1. © Kaufland 2016 | ABAP CODERETREAT WEINSBERG Unit Testing KIS, Weinsberg, 23.07.2016 ABAP CodeRetreat Weinsberg121.07.2016
  • 2. © Kaufland 2016 | WHO WE ARE KAUFLAND We are more than just a successful international trading company: We are a company where many colleagues become a team, jobs are safe workplaces and real satisfaction Diversity and stability We offer a wide range of jobs with many different entry-levels and career opportunities. Our company is continuously growing, that makes us self-confident Openness and friendly cooperation We support a cooperation based on friendliness and mutual trust ABAP CodeRetreat Weinsberg221.07.2016
  • 3. © Kaufland 2016 | WHERE WE ARE KAUFLAND Expansive growth, economic size • We are successfully expanding in Germany, Poland, Czech Republic, Slovakia, Croatia, Romania and Bulgaria • Over 150,500 employees form our strong Kaufland team in Europe International cooperation and prospects • We offer an international work environment • We provide a wide variety of tasks in collaboration with our international colleagues • According to the area of deployment you will have the opportunity to collect experience abroad, in one of our European locations ABAP CodeRetreat Weinsberg321.07.2016
  • 4. © Kaufland 2016 | ABAP CodeRetreat Weinsberg4 KAUFLAND INFORMATION SYSTEMS We are the IT service provider for Kaufland. Ensuring high business performance and carrying data streams on the right track is our daily responsibility Keep IT simple and safe Our objectives are to comprehensively advice our business departments in designing their business processes and to implement software solutions OUR IT IN FIGURES 21.07.2016 220 SAP Systems 40 SAP Developers 25k Z Reports
  • 5. © Kaufland 2016 | UNIT TESTING ABAP CodeRetreat Weinsberg521.07.2016 Unit Testing Integration Testing System Testing Acceptance Testing
  • 6. © Kaufland 2016 | ABAP CodeRetreat Weinsberg6 • Set up an initial state • Confront the method under test with test values • Compare actual value with expected test value • Implemented in form of test methods • Test methods are hosted in a test class • Test classes are local classes to the program object under test • Use global test classes only to host reusable logic for tests • Comparisons are done with class CL_ABAP_UNIT_ASSERT UNIT TESTS ABAP UNIT TESTS CREATING ABAP UNIT TESTS UNIT TESTING 21.07.2016
  • 7. © Kaufland 2016 | • Test classes are local classes defined with the FOR TESTING addition • Test methods are (private) parameterless instance methods, also declared with the FOR TESTING addition • Use Fixtures to ensure particular starting conditions • [class] setup and [class] teardown TEST CLASSES AND TEST METHODS ABAP CodeRetreat Weinsberg7 UNIT TESTING 21.07.2016 setup( ). teardown( ). my_first_test_method( ).
  • 8. © Kaufland 2016 | EXAMPLE ABAP CodeRetreat Weinsberg8 UNIT TESTING 21.07.2016
  • 9. © Kaufland 2016 | • Testing starts already during the design of your application • The following slides show some pitfalls you should keep in mind • All coding samples are more or less pseudo-code in ABAP style PREPARATION ABAP CodeRetreat Weinsberg9 UNIT TESTING 21.07.2016
  • 10. © Kaufland 2016 | ABAP CodeRetreat Weinsberg10 PITFALL #1 CLASS car. PRIVATE SECTION. DATA g_fuel TYPE i. PUBLIC SECTION. set_fuel IMPORTING i_fuel TYPE i. has_fuel RETURNING r_has_fuel TYPE xfeld. ENDCLASS. CLASS testcar FOR TESTING. PRIVATE SECTION. DATA g_testobject TYPE REF TO car. METHOD class_setup. g_testobject = NEW #( ). METHOD test_fuel. g_testobject->set_fuel( 30 ). METHOD test_has_fuel. DATA(has_fuel) = g_test_object->has_fuel( ). ENDCLASS. UNIT TESTING 21.07.2016 • Test cases guarantee no order! • When method test_has_fuel() is called we do not know in which state the test- object already is! • Take care to initialize your test-object before each testcase so that you know the current state! (e.g. use setup() instead of class_setup()) Each testmethod has to return the same result each time it's called otherwise we cannot test it.
  • 11. © Kaufland 2016 | ABAP CodeRetreat Weinsberg11 PITFALL #2 CLASS order. DATA g_order_number TYPE i. METHOD get_positions. " load data SELECT * FROM mseg WHERE mblnr = g_order_number. " prepare data " do something else " return result. ENDCLASS. UNIT TESTING 21.07.2016 • We do not know what is currently in the database! • We do not know which data will be prepared! • We cannot assume what data will be returned! Do not load information from sources that cannot be controlled during testing. Load data before instantiating the order object. This will enable us to write a testmethod for the data preparation. Alternative solution: use a database- handler-class and pass it as a parameter. During testing you can use a mock of the database-handler that returns fix results.
  • 12. © Kaufland 2016 | ABAP CodeRetreat Weinsberg12 PITFALL #3 CLASS store. METHOD is_opened. CALL FUNCTION 'DATE_COMPUTE_DAY' EXPORTING date = sy-datum IMPORTING day = day. IF day <> 7. r_is_opened = abap_true. ENDIF. ENDCLASS. UNIT TESTING 21.07.2016 • If we expect the store to be closed the testmethod will only succeed on sundays • Testmethods expect a hard-coded result. Not possible in this case! Don't use system (or other) variables that you cannot control. Better give the date as parameter. So your testmethod can call testobject->is_opened( '20160505' ).
  • 13. © Kaufland 2016 | ABAP CodeRetreat Weinsberg13 UNIT TESTING 21.07.2016 POSSIBLE ARCHITECTURE Database Database provider Business object Data Access Object (DAO) Database layer Business layerAccess layer
  • 14. © Kaufland 2016 | • Sample Reports in package: SABP_UNIT_SAMPLE • Executing Tests: Ctrl + Shift + F10 • Verification of test expectations: CL_ABAP_UNIT_ASSERT • Test classes and methods are defined / declared with the FOR TESTING addition • Considerations on how to write testable code must be included in the design avoid the pitfalls HOW TO GET STARTED / KEY TAKEAWAYS ABAP CodeRetreat Weinsberg14 UNIT TESTING 21.07.2016