SlideShare a Scribd company logo
1 of 20
AUTOMATED TESTS
SERGII IVASHCHENKO
ON EXAMPLE OF MAGENTO 2
AUTOMATED TESTS BY @SERGEIVASCHENKO
WHOAMI
▸ PHP Developer from Ukraine
▸ Ex Magento Core Developer
▸ Magento Testing Framework
▸ Created a lot of tests
▸ sivaschenko.com
▸ @sergeivaschenko
AUTOMATED TESTS BY @SERGEIVASCHENKO
WHY MAGENTO 2 IS A GOOD EXAMPLE
▸ Big and versatile project
▸ More a solution then a framework
▸ Many tests of all types
▸ Open Source https://github.com/magento/
magento2
AUTOMATED TESTS BY @SERGEIVASCHENKO
THE PLAN
▸ Go through each type of test
▸ Definition
▸ Compare
▸ Magento 2
▸ Alternatives
▸ Your current project
AUTOMATED TESTS BY @SERGEIVASCHENKO
FACTORS FOR COMPARISON
▸ Code coverage accuracy
▸ Functionality coverage accuracy
▸ Creation efforts (complexity x time)
▸ Maintenance efforts (sensitivity + stability)
AUTOMATED TESTS BY @SERGEIVASCHENKO
UNIT
▸ Testing one class in isolation
▸ Precise code coverage
▸ Lots of routine work to create
▸ Very sensitive to code changes
▸ Magento 2: pure PHPUnit + easy dependency
mocking
AUTOMATED TESTS BY @SERGEIVASCHENKO
EXAMPLES
▸ Test case: https://github.com/magento/magento2/blob/
develop/app/code/Magento/Catalog/Test/Unit/Block/
NavigationTest.php
▸ Configuration: https://github.com/magento/magento2/
blob/develop/dev/tests/unit/phpunit.xml.dist
▸ Test Framework Object Manager: https://github.com/
magento/magento2/blob/develop/lib/internal/Magento/
Framework/TestFramework/Unit/Helper/
ObjectManager.php
AUTOMATED TESTS BY @SERGEIVASCHENKO
INTEGRATION
▸ Testing method call without any code isolation
▸ Between unit and functional
▸ Often complicated preconditions
▸ Not sensitive to low level code changes (but to app
state)
▸ Magento 2: fixtures, db and app isolation, abstract
layer for controllers
AUTOMATED TESTS BY @SERGEIVASCHENKO
EXAMPLES
▸ Test case: https://github.com/magento/magento2/blob/
develop/dev/tests/integration/testsuite/Magento/Catalog/
Controller/ProductTest.php
▸ Annotations: https://github.com/magento/magento2/tree/
develop/dev/tests/integration/framework/Magento/
TestFramework/Annotation
▸ Abstract Layer: https://github.com/magento/magento2/
tree/develop/dev/tests/integration/framework/Magento/
TestFramework/TestCase
AUTOMATED TESTS BY @SERGEIVASCHENKO
WEB API
▸ Web API request/response validation
▸ Between integration and functional
▸ Requires preconditions
▸ Not sensitive to low level code changes (but to
app state)
▸ Magento 2: abstract layer
AUTOMATED TESTS BY @SERGEIVASCHENKO
EXAMPLES
▸ Test case: https://github.com/magento/
magento2/blob/develop/dev/tests/api-
functional/testsuite/Magento/Catalog/Api/
AttributeSetRepositoryTest.php
▸ Abstract: https://github.com/magento/
magento2/blob/develop/dev/tests/api-
functional/framework/Magento/TestFramework/
TestCase/WebapiAbstract.php
AUTOMATED TESTS BY @SERGEIVASCHENKO
FUNCTIONAL
▸ Browser scenarios
▸ Precise functionality coverage
▸ Efforts = amount of JS
▸ Sensitive to interface changes
▸ Magento 2: MTF https://github.com/magento/
mtf
AUTOMATED TESTS BY @SERGEIVASCHENKO
EXAMPLES
▸ Test case: https://github.com/magento/
magento2/blob/develop/dev/tests/functional/
tests/app/Magento/Customer/Test/TestCase/
CreateCustomerGroupEntityTest.php
▸ Test case config: https://github.com/magento/
magento2/blob/develop/dev/tests/functional/
tests/app/Magento/Customer/Test/TestCase/
CreateCustomerGroupEntityTest.xml
Codecoverageaccuracy
0
2
4
6
8
Functionality coverage accuracy
0 2 4 6 8
Unit Integration Web API
Functional
AUTOMATED TESTS BY @SERGEIVASCHENKO
STATIC
▸ Do not require functional code execution
▸ Can be reused between projects/companies/etc
▸ Code standards, typos, potential errors, complexity,
dependency issues
▸ Use those right now: phpmd, phpcs, phpcpd, php-
cs-fixer, pdepend, phpcbf, etc (and even PHPSorm
code inspection)
AUTOMATED TESTS BY @SERGEIVASCHENKO
EXAMPLES
▸ Copy-paste, mess, standards test: https://
github.com/magento/magento2/blob/develop/
dev/tests/static/testsuite/Magento/Test/Php/
LiveCodeTest.php
▸ Obsolete references: https://github.com/
magento/magento2/blob/develop/dev/tests/
static/testsuite/Magento/Test/Legacy/_files/
obsolete_config_nodes.php
AUTOMATED TESTS BY @SERGEIVASCHENKO
PERFORMANCE
▸ Tests result depends on execution time, requests
throughput
▸ Tests on system loaded with data
▸ Magento 2:
▸ Performance fixtures (data generation)
▸ New Relic reporting
AUTOMATED TESTS BY @SERGEIVASCHENKO
EXAMPLES
▸ Profiles for data generation: https://
github.com/magento/magento2/tree/
develop/setup/performance-toolkit/profiles/
ce
▸ JMeter test suite: https://github.com/
magento/magento2/blob/develop/setup/
performance-toolkit/benchmark.jmx
AUTOMATED TESTS BY @SERGEIVASCHENKO
INTERESTING READ
▸ PHP Native Mocking https://medium.com/
@IvanChepurnyi/native-mocking-and-
stubbing-in-php-ad11a32596e4
▸ Magento automated tests by Magento VP of
Architecture: https://alankent.me/
2014/06/28/magento-2-test-automation/
THANK YOU!
@SERGEIVASCHENK

More Related Content

What's hot

What's hot (20)

OSMC 2017 | Extending NSClient++ by Michael Medin
OSMC 2017 | Extending NSClient++ by Michael MedinOSMC 2017 | Extending NSClient++ by Michael Medin
OSMC 2017 | Extending NSClient++ by Michael Medin
 
Extending NSClient++ with rest and python
Extending NSClient++ with rest and pythonExtending NSClient++ with rest and python
Extending NSClient++ with rest and python
 
Angular 2 Básico
Angular 2 BásicoAngular 2 Básico
Angular 2 Básico
 
GWTcon 2015 - Beyond GWT 3.0 Panic
GWTcon 2015 - Beyond GWT 3.0 PanicGWTcon 2015 - Beyond GWT 3.0 Panic
GWTcon 2015 - Beyond GWT 3.0 Panic
 
Bootiful Reactive Testing with Mario Gray
Bootiful Reactive Testing with Mario GrayBootiful Reactive Testing with Mario Gray
Bootiful Reactive Testing with Mario Gray
 
Github tutorial1
Github tutorial1Github tutorial1
Github tutorial1
 
Visual Studio App Center: React Native A/B Testing
Visual Studio App Center: React Native A/B TestingVisual Studio App Center: React Native A/B Testing
Visual Studio App Center: React Native A/B Testing
 
Typescript - a JS superset
Typescript - a JS supersetTypescript - a JS superset
Typescript - a JS superset
 
Steps to deploy mule application with munit on cloudhub using jenkins pipeline
Steps to deploy mule application with munit on cloudhub using jenkins pipelineSteps to deploy mule application with munit on cloudhub using jenkins pipeline
Steps to deploy mule application with munit on cloudhub using jenkins pipeline
 
[WroclawJUG] Continuous Delivery in OSS using Shipkit
[WroclawJUG] Continuous Delivery in OSS using Shipkit[WroclawJUG] Continuous Delivery in OSS using Shipkit
[WroclawJUG] Continuous Delivery in OSS using Shipkit
 
Continuous Delivery in OSS using Shipkit.org
Continuous Delivery in OSS using Shipkit.orgContinuous Delivery in OSS using Shipkit.org
Continuous Delivery in OSS using Shipkit.org
 
Gitflow Workflow
Gitflow WorkflowGitflow Workflow
Gitflow Workflow
 
Continuously Break The Android
Continuously Break The AndroidContinuously Break The Android
Continuously Break The Android
 
Porting golang development environment developed with golang
Porting golang development environment developed with golangPorting golang development environment developed with golang
Porting golang development environment developed with golang
 
Open Source Swift: Up and Running
Open Source Swift: Up and RunningOpen Source Swift: Up and Running
Open Source Swift: Up and Running
 
1. Quick sartup a jenkins server on OpenShift
1. Quick sartup a jenkins server on OpenShift1. Quick sartup a jenkins server on OpenShift
1. Quick sartup a jenkins server on OpenShift
 
Releasing with gradle (gradle summit 2014)
Releasing with gradle (gradle summit 2014)Releasing with gradle (gradle summit 2014)
Releasing with gradle (gradle summit 2014)
 
Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.
 
(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer
 
PhoneGap
PhoneGapPhoneGap
PhoneGap
 

Viewers also liked

We've been building this for years now
We've been building this for years nowWe've been building this for years now
We've been building this for years now
Jacob Oduor
 

Viewers also liked (15)

Introduction to UI Components in Magento 2
Introduction to UI Components in Magento 2Introduction to UI Components in Magento 2
Introduction to UI Components in Magento 2
 
We've been building this for years now
We've been building this for years nowWe've been building this for years now
We've been building this for years now
 
Cleared Job Fair Job Seeker Handbook April 6, 2017, Tysons Corner, VA
Cleared Job Fair Job Seeker Handbook April 6, 2017, Tysons Corner, VACleared Job Fair Job Seeker Handbook April 6, 2017, Tysons Corner, VA
Cleared Job Fair Job Seeker Handbook April 6, 2017, Tysons Corner, VA
 
Simple flat ui css accordion
Simple flat ui css accordionSimple flat ui css accordion
Simple flat ui css accordion
 
Lil bibby
Lil bibbyLil bibby
Lil bibby
 
Vincent Laberge colloque EDUlib 2017
Vincent Laberge colloque EDUlib 2017Vincent Laberge colloque EDUlib 2017
Vincent Laberge colloque EDUlib 2017
 
C All 2008 7 26
C All 2008 7 26C All 2008 7 26
C All 2008 7 26
 
Carta Náutica do Porto de Lisboa - março de 2017
Carta Náutica do Porto de Lisboa - março de 2017Carta Náutica do Porto de Lisboa - março de 2017
Carta Náutica do Porto de Lisboa - março de 2017
 
Do work
Do workDo work
Do work
 
Pierce Transit White Paper Summary for 25th ESV Conference
Pierce Transit White Paper Summary for 25th ESV ConferencePierce Transit White Paper Summary for 25th ESV Conference
Pierce Transit White Paper Summary for 25th ESV Conference
 
Sosiale media vir klein sake
Sosiale media vir klein sakeSosiale media vir klein sake
Sosiale media vir klein sake
 
N2W Partnership overview
N2W Partnership overviewN2W Partnership overview
N2W Partnership overview
 
Newington
NewingtonNewington
Newington
 
Ecopol tech portfolio construction polymers
Ecopol tech portfolio construction polymersEcopol tech portfolio construction polymers
Ecopol tech portfolio construction polymers
 
B2B Marketing Disruption
B2B Marketing DisruptionB2B Marketing Disruption
B2B Marketing Disruption
 

Similar to Automated tests types on Magento 2 example

Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacript
Lei Kang
 

Similar to Automated tests types on Magento 2 example (20)

Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
 
Magento 2 integration tests
Magento 2 integration testsMagento 2 integration tests
Magento 2 integration tests
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacript
 
Real Impact Testing Analysis For JVM
Real Impact Testing Analysis For JVMReal Impact Testing Analysis For JVM
Real Impact Testing Analysis For JVM
 
Contract testing - isolated testing of microservices - Symfony Camp 2018, Evg...
Contract testing - isolated testing of microservices - Symfony Camp 2018, Evg...Contract testing - isolated testing of microservices - Symfony Camp 2018, Evg...
Contract testing - isolated testing of microservices - Symfony Camp 2018, Evg...
 
Contract testing symfony camp 2018
  Contract testing symfony camp 2018  Contract testing symfony camp 2018
Contract testing symfony camp 2018
 
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
 
Testing with JUnit 5 and Spring
Testing with JUnit 5 and SpringTesting with JUnit 5 and Spring
Testing with JUnit 5 and Spring
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
DCVCS using GIT
DCVCS using GITDCVCS using GIT
DCVCS using GIT
 
Composer and Git in Magento
Composer and Git in MagentoComposer and Git in Magento
Composer and Git in Magento
 
Real Impact Testing Analysis for JVM developers
Real Impact Testing Analysis for JVM developersReal Impact Testing Analysis for JVM developers
Real Impact Testing Analysis for JVM developers
 
Magento Functional Testing Framework a way to seriously write automated tests...
Magento Functional Testing Framework a way to seriously write automated tests...Magento Functional Testing Framework a way to seriously write automated tests...
Magento Functional Testing Framework a way to seriously write automated tests...
 
Introduction to Integration Tests in Magento / Adobe Commerce
Introduction to Integration Tests in Magento / Adobe CommerceIntroduction to Integration Tests in Magento / Adobe Commerce
Introduction to Integration Tests in Magento / Adobe Commerce
 
Introduction to Integration Tests in Magento / Adobe Commerce
Introduction to Integration Tests in Magento / Adobe CommerceIntroduction to Integration Tests in Magento / Adobe Commerce
Introduction to Integration Tests in Magento / Adobe Commerce
 
Magento 2: New and Innovative? - php[world] 2015
Magento 2: New and Innovative? - php[world] 2015Magento 2: New and Innovative? - php[world] 2015
Magento 2: New and Innovative? - php[world] 2015
 
Exploring the GitHub Service Universe
Exploring the GitHub Service UniverseExploring the GitHub Service Universe
Exploring the GitHub Service Universe
 
Selenium cloud
Selenium cloudSelenium cloud
Selenium cloud
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 

Recently uploaded

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 

Automated tests types on Magento 2 example

  • 2. AUTOMATED TESTS BY @SERGEIVASCHENKO WHOAMI ▸ PHP Developer from Ukraine ▸ Ex Magento Core Developer ▸ Magento Testing Framework ▸ Created a lot of tests ▸ sivaschenko.com ▸ @sergeivaschenko
  • 3. AUTOMATED TESTS BY @SERGEIVASCHENKO WHY MAGENTO 2 IS A GOOD EXAMPLE ▸ Big and versatile project ▸ More a solution then a framework ▸ Many tests of all types ▸ Open Source https://github.com/magento/ magento2
  • 4. AUTOMATED TESTS BY @SERGEIVASCHENKO THE PLAN ▸ Go through each type of test ▸ Definition ▸ Compare ▸ Magento 2 ▸ Alternatives ▸ Your current project
  • 5. AUTOMATED TESTS BY @SERGEIVASCHENKO FACTORS FOR COMPARISON ▸ Code coverage accuracy ▸ Functionality coverage accuracy ▸ Creation efforts (complexity x time) ▸ Maintenance efforts (sensitivity + stability)
  • 6. AUTOMATED TESTS BY @SERGEIVASCHENKO UNIT ▸ Testing one class in isolation ▸ Precise code coverage ▸ Lots of routine work to create ▸ Very sensitive to code changes ▸ Magento 2: pure PHPUnit + easy dependency mocking
  • 7. AUTOMATED TESTS BY @SERGEIVASCHENKO EXAMPLES ▸ Test case: https://github.com/magento/magento2/blob/ develop/app/code/Magento/Catalog/Test/Unit/Block/ NavigationTest.php ▸ Configuration: https://github.com/magento/magento2/ blob/develop/dev/tests/unit/phpunit.xml.dist ▸ Test Framework Object Manager: https://github.com/ magento/magento2/blob/develop/lib/internal/Magento/ Framework/TestFramework/Unit/Helper/ ObjectManager.php
  • 8. AUTOMATED TESTS BY @SERGEIVASCHENKO INTEGRATION ▸ Testing method call without any code isolation ▸ Between unit and functional ▸ Often complicated preconditions ▸ Not sensitive to low level code changes (but to app state) ▸ Magento 2: fixtures, db and app isolation, abstract layer for controllers
  • 9. AUTOMATED TESTS BY @SERGEIVASCHENKO EXAMPLES ▸ Test case: https://github.com/magento/magento2/blob/ develop/dev/tests/integration/testsuite/Magento/Catalog/ Controller/ProductTest.php ▸ Annotations: https://github.com/magento/magento2/tree/ develop/dev/tests/integration/framework/Magento/ TestFramework/Annotation ▸ Abstract Layer: https://github.com/magento/magento2/ tree/develop/dev/tests/integration/framework/Magento/ TestFramework/TestCase
  • 10. AUTOMATED TESTS BY @SERGEIVASCHENKO WEB API ▸ Web API request/response validation ▸ Between integration and functional ▸ Requires preconditions ▸ Not sensitive to low level code changes (but to app state) ▸ Magento 2: abstract layer
  • 11. AUTOMATED TESTS BY @SERGEIVASCHENKO EXAMPLES ▸ Test case: https://github.com/magento/ magento2/blob/develop/dev/tests/api- functional/testsuite/Magento/Catalog/Api/ AttributeSetRepositoryTest.php ▸ Abstract: https://github.com/magento/ magento2/blob/develop/dev/tests/api- functional/framework/Magento/TestFramework/ TestCase/WebapiAbstract.php
  • 12. AUTOMATED TESTS BY @SERGEIVASCHENKO FUNCTIONAL ▸ Browser scenarios ▸ Precise functionality coverage ▸ Efforts = amount of JS ▸ Sensitive to interface changes ▸ Magento 2: MTF https://github.com/magento/ mtf
  • 13. AUTOMATED TESTS BY @SERGEIVASCHENKO EXAMPLES ▸ Test case: https://github.com/magento/ magento2/blob/develop/dev/tests/functional/ tests/app/Magento/Customer/Test/TestCase/ CreateCustomerGroupEntityTest.php ▸ Test case config: https://github.com/magento/ magento2/blob/develop/dev/tests/functional/ tests/app/Magento/Customer/Test/TestCase/ CreateCustomerGroupEntityTest.xml
  • 14. Codecoverageaccuracy 0 2 4 6 8 Functionality coverage accuracy 0 2 4 6 8 Unit Integration Web API Functional
  • 15. AUTOMATED TESTS BY @SERGEIVASCHENKO STATIC ▸ Do not require functional code execution ▸ Can be reused between projects/companies/etc ▸ Code standards, typos, potential errors, complexity, dependency issues ▸ Use those right now: phpmd, phpcs, phpcpd, php- cs-fixer, pdepend, phpcbf, etc (and even PHPSorm code inspection)
  • 16. AUTOMATED TESTS BY @SERGEIVASCHENKO EXAMPLES ▸ Copy-paste, mess, standards test: https:// github.com/magento/magento2/blob/develop/ dev/tests/static/testsuite/Magento/Test/Php/ LiveCodeTest.php ▸ Obsolete references: https://github.com/ magento/magento2/blob/develop/dev/tests/ static/testsuite/Magento/Test/Legacy/_files/ obsolete_config_nodes.php
  • 17. AUTOMATED TESTS BY @SERGEIVASCHENKO PERFORMANCE ▸ Tests result depends on execution time, requests throughput ▸ Tests on system loaded with data ▸ Magento 2: ▸ Performance fixtures (data generation) ▸ New Relic reporting
  • 18. AUTOMATED TESTS BY @SERGEIVASCHENKO EXAMPLES ▸ Profiles for data generation: https:// github.com/magento/magento2/tree/ develop/setup/performance-toolkit/profiles/ ce ▸ JMeter test suite: https://github.com/ magento/magento2/blob/develop/setup/ performance-toolkit/benchmark.jmx
  • 19. AUTOMATED TESTS BY @SERGEIVASCHENKO INTERESTING READ ▸ PHP Native Mocking https://medium.com/ @IvanChepurnyi/native-mocking-and- stubbing-in-php-ad11a32596e4 ▸ Magento automated tests by Magento VP of Architecture: https://alankent.me/ 2014/06/28/magento-2-test-automation/