SlideShare une entreprise Scribd logo
1  sur  39
Télécharger pour lire hors ligne
© 2019 Magento, Inc. Page | 1
API Functional
Testing in Magento 2.3
© 2019 Magento, Inc.
.
Page | 2
Senior Software Developer at BORN Group
Vishwas Bhatnagar
https://www.linkedin.com/in/vishwasbhatnagar/
© 2019 Magento, Inc. Page | 3
Agenda
© 2019 Magento, Inc. Page | 4
Agenda
• Testing In Magento 2
• What is API Functional Testing ?
• Why Do we need API Functional Testing
• API Functional test case writing
• Configuring , running and cleanup after test cases
© 2019 Magento, Inc. Page | 5
Not In Scope
© 2019 Magento, Inc. Page | 6
Not in Scope
• Unit Tests
• Integrations Tests
• Functional Tests
• Magento Testing Framework using Selenium
© 2019 Magento, Inc. Page | 7
Testing In Magento 2
© 2019 Magento, Inc. Page | 8
Tests available in Magento 2
 Unit Tests
 Integration Tests
 Functional Tests
 Performance Tests
 Static Code Analysis Tests
 JavaScript Tests
 Integrity Tests
 Legacy Tests
© 2019 Magento, Inc. Page | 9
Unit Testing
 Individual classes or functions in isolation
 Resides in dev/tests/unit
© 2019 Magento, Inc. Page | 10
Integration Tests
• Interactions between
components, layers, and the
environment
• dev/tests/integration
© 2019 Magento, Inc. Page | 11
Functional Tests
 Same way user would interact
 dev/tests/functional and dev/tests/api-functional
Functional
Test
API
Functional
MTF
© 2019 Magento, Inc. Page | 12
Performance Tests
 Track and maintain performance level per build
 dev/tests/performance
© 2019 Magento, Inc. Page | 13
Few more tests
 Static Code Analysis Tests :
 Static code analysis checks that PHP code
follows the Magento 2 coding standards and
best practices(dev/tests/static)
 JavaScript Tests :
 Tests the accuracy of JavaScript functions.
 (dev/tests/js).
 Integrity testing
 check how an application is linked.
 Basically, they tell us if your application
should be able to run.
 Legacy Tests
© 2019 Magento, Inc. Page | 14
What is API Functional
Testing ?
© 2019 Magento, Inc. Page | 15
API Functional Tests
• Process used within software
development in which software
is tested to ensure that it
conforms with all
requirements.
• Makes sure that nothing visible
to the customer broke.
• Don't care about how
something is built
• Don't care How something
works at a high level
© 2019 Magento, Inc. Page | 16
Why Do we need API
Functional Testing
© 2019 Magento, Inc. Page | 17
API Functional Testing Advantages
• Adheres with Agile software
Development
• Testing parallel with
development
• Finds problems early in the
development cycle
• Allows easy the programmer to
refactor code or upgrade
• Writing the test first forces you
to think through your design
and what it must accomplish
before you write the code
© 2019 Magento, Inc. Page | 18
Getting Started
© 2019 Magento, Inc.
.
Page | 19
Writing Test cases
• Should inherit from the generic test case
MagentoTestFrameworkTestCaseWebapiAbstract.
• Should Use ObjectManager for testing in isolation
• Class /File name should end with test
• Methods should start with test
• All Methods should be declared public
© 2019 Magento, Inc.
.
Page | 20
Sample Test cases
© 2019 Magento, Inc.
.
Page | 21
Assertions
You can make various assertions that
are available in
phpunitFrameworkAssert like
• assertArrayHasKey
• assertCount
• assertSame
• assertEquals
• assertNotEmpty
• assertGreaterThan
• assertIsReadable
• assertNotNull
© 2019 Magento, Inc.
.
Page | 22
Assertion Example
© 2019 Magento, Inc. Page | 23
Running Test Cases
© 2019 Magento, Inc.
.
Page | 24
Configuring magento to run tests
• Copy /dev/tests/api-functional/phpunit_rest.xml.dist to
/dev/tests/api-functional/phpunit_rest.xml
© 2019 Magento, Inc.
.
Page | 25
Configuring magento to run tests
• Copy /dev/tests/api-functional/config/install-config-
mysql.php.dist to /dev/tests/api-functional/config/install-config-
mysql.php.
• Configure your DB connection and install
© 2019 Magento, Inc.
.
Page | 26
Running Using CLI
• Switch to M2_ROOT/dev/test/api-fuctional/
• To Run Test class
– ../../../vendor/bin/phpunit --debug
../../../app/code/Born/VehicleSearch/Test/Api/JobPostTest
• To run a test method
– ../../../vendor/bin/phpunit --debug --filter testJobSaveNoAction
../../../app/code/Born/Jobs/Test/Api/JobPostTest
© 2019 Magento, Inc.
.
Page | 27
Running Using CLI
© 2019 Magento, Inc.
.
Page | 28
Analyzing the Test Result
© 2019 Magento, Inc. Page | 29
Complex Test case Writing ?
© 2019 Magento, Inc. Page | 30
Use DocBlock Annotations
@magentoAppIsolation :
• Enable and Disable
• Application state after a test
run will be the same as before
the test run
@magentoDbIsolation :
• Enable and Disable
• All data, required for a test,
live during transaction only.
Any test results won’t be
written in a database.
© 2019 Magento, Inc. Page | 31
@magentoDataFixture/magentoApiDataFixture:
• Used to setup environment
• All data, required for a test, live during transaction only. Any test results
won’t be written in a database
@magentoAppArea :
• Adminhtml | frontend | global
• Set area to application
© 2019 Magento, Inc. Page | 32
@magentoCache:
• <type>|all enabled|disabled
• Disables cache
@magentoConfigFixture :
• [<store_code>_store] <config_path> <config_value>
• Configuration values for individual tests and revert them after the test
execution
© 2019 Magento, Inc.
.
Page | 33
Fixture Example
© 2019 Magento, Inc. Page | 34
Clean it Up !
© 2019 Magento, Inc. Page | 35
Cleaning data after test case execution
• RollBack Scripts
– If you use fixtures to insert
data you can create a rollback
script for it .
– Same format as the
corresponding fixture: a script
or a method
– Should be Stored in the same
directory
– Same class as the
corresponding fixture and
suffixed with Rollback
© 2019 Magento, Inc.
.
Page | 36
Cleaning data after test case execution
Script
Fixture : Magento/Catalog/_files/categories.php
RollBack : Magento/Catalog/_files/categories_rollback.php
Method
Fixture : MagentoCatalogModelProductTest::prepareProduct
RollBack : MagentoCatalogModelProductTest::prepareProductRollback
© 2019 Magento, Inc.
.
Page | 37
Cleaning data after test case execution
• TearDown Method
– If you want to perform any actions after constraints
– To be included in test case file
© 2019 Magento, Inc. Page | 38
Questions ?
© 2019 Magento, Inc. Page | 39
Thank You

Contenu connexe

Tendances

ProGuard / DexGuard Tips and Tricks
ProGuard / DexGuard Tips and TricksProGuard / DexGuard Tips and Tricks
ProGuard / DexGuard Tips and Tricksnetomi
 
Interface fonctionnelle, Lambda expression, méthode par défaut, référence de...
Interface fonctionnelle, Lambda expression, méthode par défaut,  référence de...Interface fonctionnelle, Lambda expression, méthode par défaut,  référence de...
Interface fonctionnelle, Lambda expression, méthode par défaut, référence de...MICHRAFY MUSTAFA
 
Difference between xml and json
Difference between xml and jsonDifference between xml and json
Difference between xml and jsonUmar Ali
 
Une introduction à Javascript et ECMAScript 6
Une introduction à Javascript et ECMAScript 6Une introduction à Javascript et ECMAScript 6
Une introduction à Javascript et ECMAScript 6Jean-Baptiste Vigneron
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerKoichi Sakata
 
Laravel の paginate は一体何をやっているのか
Laravel の paginate は一体何をやっているのかLaravel の paginate は一体何をやっているのか
Laravel の paginate は一体何をやっているのかShohei Okada
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hackingJeroen van Dijk
 
Lineにおけるspring frameworkの活用
Lineにおけるspring frameworkの活用Lineにおけるspring frameworkの活用
Lineにおけるspring frameworkの活用Tokuhiro Matsuno
 
Spring starterによるSpring Boot Starter
Spring starterによるSpring Boot StarterSpring starterによるSpring Boot Starter
Spring starterによるSpring Boot StarterRyosuke Uchitate
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8AppDynamics
 
Appium & Robot Framework
Appium & Robot FrameworkAppium & Robot Framework
Appium & Robot FrameworkFurkan Ertürk
 
My Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API'sMy Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API'sRoel Hartman
 
4장. Class Loader
4장. Class Loader4장. Class Loader
4장. Class Loader김 한도
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentationBhavin Shah
 

Tendances (20)

ProGuard / DexGuard Tips and Tricks
ProGuard / DexGuard Tips and TricksProGuard / DexGuard Tips and Tricks
ProGuard / DexGuard Tips and Tricks
 
Interface fonctionnelle, Lambda expression, méthode par défaut, référence de...
Interface fonctionnelle, Lambda expression, méthode par défaut,  référence de...Interface fonctionnelle, Lambda expression, méthode par défaut,  référence de...
Interface fonctionnelle, Lambda expression, méthode par défaut, référence de...
 
Thinking in react
Thinking in reactThinking in react
Thinking in react
 
Difference between xml and json
Difference between xml and jsonDifference between xml and json
Difference between xml and json
 
Une introduction à Javascript et ECMAScript 6
Une introduction à Javascript et ECMAScript 6Une introduction à Javascript et ECMAScript 6
Une introduction à Javascript et ECMAScript 6
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 
Laravel の paginate は一体何をやっているのか
Laravel の paginate は一体何をやっているのかLaravel の paginate は一体何をやっているのか
Laravel の paginate は一体何をやっているのか
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
JVM Under The Hood WDI.pdf
JVM Under The Hood WDI.pdfJVM Under The Hood WDI.pdf
JVM Under The Hood WDI.pdf
 
Lineにおけるspring frameworkの活用
Lineにおけるspring frameworkの活用Lineにおけるspring frameworkの活用
Lineにおけるspring frameworkの活用
 
Spring starterによるSpring Boot Starter
Spring starterによるSpring Boot StarterSpring starterによるSpring Boot Starter
Spring starterによるSpring Boot Starter
 
SwiftのDI方法につい て最近考えてた話
SwiftのDI方法につい て最近考えてた話SwiftのDI方法につい て最近考えてた話
SwiftのDI方法につい て最近考えてた話
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8
 
Appium & Robot Framework
Appium & Robot FrameworkAppium & Robot Framework
Appium & Robot Framework
 
My Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API'sMy Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API's
 
4장. Class Loader
4장. Class Loader4장. Class Loader
4장. Class Loader
 
Maven
MavenMaven
Maven
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Angular.pdf
Angular.pdfAngular.pdf
Angular.pdf
 
Angular 11
Angular 11Angular 11
Angular 11
 

Similaire à Magento2.3 API Functional Testing

Max Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMax Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMeet Magento Italy
 
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceEugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceMeet Magento Italy
 
Magento Function Testing Framework - Intro and Overview
Magento Function Testing Framework - Intro and OverviewMagento Function Testing Framework - Intro and Overview
Magento Function Testing Framework - Intro and OverviewTom Erskine
 
Backwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLBackwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLIgor Miniailo
 
Testlink Test Management with Teamforge
Testlink Test Management with TeamforgeTestlink Test Management with Teamforge
Testlink Test Management with TeamforgeCollabNet
 
Magento 2.3 Schema and Data Patches
Magento 2.3 Schema and Data PatchesMagento 2.3 Schema and Data Patches
Magento 2.3 Schema and Data Patchesatishgoswami
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...Amazon Web Services
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...Amazon Web Services
 
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 CommerceBartosz Górski
 
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 CommerceBartosz Górski
 
API design best practices
API design best practicesAPI design best practices
API design best practicesIgor Miniailo
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...Amazon Web Services
 
Browser-Based Load Testing with Grafana K6
Browser-Based Load Testing with Grafana K6Browser-Based Load Testing with Grafana K6
Browser-Based Load Testing with Grafana K6Knoldus Inc.
 
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...Amazon Web Services
 
Automated Testing in Magento 2
Automated Testing in Magento 2Automated Testing in Magento 2
Automated Testing in Magento 2Magecom UK Limited
 
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)Igor Miniailo
 
A Complete Guide to Functional Testing
A Complete Guide to Functional TestingA Complete Guide to Functional Testing
A Complete Guide to Functional TestingMatthew Allen
 

Similaire à Magento2.3 API Functional Testing (20)

Max Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMax Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & Quality
 
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceEugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
 
Magento Function Testing Framework - Intro and Overview
Magento Function Testing Framework - Intro and OverviewMagento Function Testing Framework - Intro and Overview
Magento Function Testing Framework - Intro and Overview
 
Backwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLBackwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NL
 
Testlink Test Management with Teamforge
Testlink Test Management with TeamforgeTestlink Test Management with Teamforge
Testlink Test Management with Teamforge
 
DevOps on AWS
DevOps on AWSDevOps on AWS
DevOps on AWS
 
Magento 2.3 Schema and Data Patches
Magento 2.3 Schema and Data PatchesMagento 2.3 Schema and Data Patches
Magento 2.3 Schema and Data Patches
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
 
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
 
Test Policy and Practices
Test Policy and PracticesTest Policy and Practices
Test Policy and Practices
 
API design best practices
API design best practicesAPI design best practices
API design best practices
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
 
Browser-Based Load Testing with Grafana K6
Browser-Based Load Testing with Grafana K6Browser-Based Load Testing with Grafana K6
Browser-Based Load Testing with Grafana K6
 
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
 
Automated Testing in Magento 2
Automated Testing in Magento 2Automated Testing in Magento 2
Automated Testing in Magento 2
 
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
 
Automate you Appium test like a pro!
Automate you Appium test like a pro!Automate you Appium test like a pro!
Automate you Appium test like a pro!
 
A Complete Guide to Functional Testing
A Complete Guide to Functional TestingA Complete Guide to Functional Testing
A Complete Guide to Functional Testing
 

Dernier

SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxAS Design & AST.
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 

Dernier (20)

SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptx
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 

Magento2.3 API Functional Testing

  • 1. © 2019 Magento, Inc. Page | 1 API Functional Testing in Magento 2.3
  • 2. © 2019 Magento, Inc. . Page | 2 Senior Software Developer at BORN Group Vishwas Bhatnagar https://www.linkedin.com/in/vishwasbhatnagar/
  • 3. © 2019 Magento, Inc. Page | 3 Agenda
  • 4. © 2019 Magento, Inc. Page | 4 Agenda • Testing In Magento 2 • What is API Functional Testing ? • Why Do we need API Functional Testing • API Functional test case writing • Configuring , running and cleanup after test cases
  • 5. © 2019 Magento, Inc. Page | 5 Not In Scope
  • 6. © 2019 Magento, Inc. Page | 6 Not in Scope • Unit Tests • Integrations Tests • Functional Tests • Magento Testing Framework using Selenium
  • 7. © 2019 Magento, Inc. Page | 7 Testing In Magento 2
  • 8. © 2019 Magento, Inc. Page | 8 Tests available in Magento 2  Unit Tests  Integration Tests  Functional Tests  Performance Tests  Static Code Analysis Tests  JavaScript Tests  Integrity Tests  Legacy Tests
  • 9. © 2019 Magento, Inc. Page | 9 Unit Testing  Individual classes or functions in isolation  Resides in dev/tests/unit
  • 10. © 2019 Magento, Inc. Page | 10 Integration Tests • Interactions between components, layers, and the environment • dev/tests/integration
  • 11. © 2019 Magento, Inc. Page | 11 Functional Tests  Same way user would interact  dev/tests/functional and dev/tests/api-functional Functional Test API Functional MTF
  • 12. © 2019 Magento, Inc. Page | 12 Performance Tests  Track and maintain performance level per build  dev/tests/performance
  • 13. © 2019 Magento, Inc. Page | 13 Few more tests  Static Code Analysis Tests :  Static code analysis checks that PHP code follows the Magento 2 coding standards and best practices(dev/tests/static)  JavaScript Tests :  Tests the accuracy of JavaScript functions.  (dev/tests/js).  Integrity testing  check how an application is linked.  Basically, they tell us if your application should be able to run.  Legacy Tests
  • 14. © 2019 Magento, Inc. Page | 14 What is API Functional Testing ?
  • 15. © 2019 Magento, Inc. Page | 15 API Functional Tests • Process used within software development in which software is tested to ensure that it conforms with all requirements. • Makes sure that nothing visible to the customer broke. • Don't care about how something is built • Don't care How something works at a high level
  • 16. © 2019 Magento, Inc. Page | 16 Why Do we need API Functional Testing
  • 17. © 2019 Magento, Inc. Page | 17 API Functional Testing Advantages • Adheres with Agile software Development • Testing parallel with development • Finds problems early in the development cycle • Allows easy the programmer to refactor code or upgrade • Writing the test first forces you to think through your design and what it must accomplish before you write the code
  • 18. © 2019 Magento, Inc. Page | 18 Getting Started
  • 19. © 2019 Magento, Inc. . Page | 19 Writing Test cases • Should inherit from the generic test case MagentoTestFrameworkTestCaseWebapiAbstract. • Should Use ObjectManager for testing in isolation • Class /File name should end with test • Methods should start with test • All Methods should be declared public
  • 20. © 2019 Magento, Inc. . Page | 20 Sample Test cases
  • 21. © 2019 Magento, Inc. . Page | 21 Assertions You can make various assertions that are available in phpunitFrameworkAssert like • assertArrayHasKey • assertCount • assertSame • assertEquals • assertNotEmpty • assertGreaterThan • assertIsReadable • assertNotNull
  • 22. © 2019 Magento, Inc. . Page | 22 Assertion Example
  • 23. © 2019 Magento, Inc. Page | 23 Running Test Cases
  • 24. © 2019 Magento, Inc. . Page | 24 Configuring magento to run tests • Copy /dev/tests/api-functional/phpunit_rest.xml.dist to /dev/tests/api-functional/phpunit_rest.xml
  • 25. © 2019 Magento, Inc. . Page | 25 Configuring magento to run tests • Copy /dev/tests/api-functional/config/install-config- mysql.php.dist to /dev/tests/api-functional/config/install-config- mysql.php. • Configure your DB connection and install
  • 26. © 2019 Magento, Inc. . Page | 26 Running Using CLI • Switch to M2_ROOT/dev/test/api-fuctional/ • To Run Test class – ../../../vendor/bin/phpunit --debug ../../../app/code/Born/VehicleSearch/Test/Api/JobPostTest • To run a test method – ../../../vendor/bin/phpunit --debug --filter testJobSaveNoAction ../../../app/code/Born/Jobs/Test/Api/JobPostTest
  • 27. © 2019 Magento, Inc. . Page | 27 Running Using CLI
  • 28. © 2019 Magento, Inc. . Page | 28 Analyzing the Test Result
  • 29. © 2019 Magento, Inc. Page | 29 Complex Test case Writing ?
  • 30. © 2019 Magento, Inc. Page | 30 Use DocBlock Annotations @magentoAppIsolation : • Enable and Disable • Application state after a test run will be the same as before the test run @magentoDbIsolation : • Enable and Disable • All data, required for a test, live during transaction only. Any test results won’t be written in a database.
  • 31. © 2019 Magento, Inc. Page | 31 @magentoDataFixture/magentoApiDataFixture: • Used to setup environment • All data, required for a test, live during transaction only. Any test results won’t be written in a database @magentoAppArea : • Adminhtml | frontend | global • Set area to application
  • 32. © 2019 Magento, Inc. Page | 32 @magentoCache: • <type>|all enabled|disabled • Disables cache @magentoConfigFixture : • [<store_code>_store] <config_path> <config_value> • Configuration values for individual tests and revert them after the test execution
  • 33. © 2019 Magento, Inc. . Page | 33 Fixture Example
  • 34. © 2019 Magento, Inc. Page | 34 Clean it Up !
  • 35. © 2019 Magento, Inc. Page | 35 Cleaning data after test case execution • RollBack Scripts – If you use fixtures to insert data you can create a rollback script for it . – Same format as the corresponding fixture: a script or a method – Should be Stored in the same directory – Same class as the corresponding fixture and suffixed with Rollback
  • 36. © 2019 Magento, Inc. . Page | 36 Cleaning data after test case execution Script Fixture : Magento/Catalog/_files/categories.php RollBack : Magento/Catalog/_files/categories_rollback.php Method Fixture : MagentoCatalogModelProductTest::prepareProduct RollBack : MagentoCatalogModelProductTest::prepareProductRollback
  • 37. © 2019 Magento, Inc. . Page | 37 Cleaning data after test case execution • TearDown Method – If you want to perform any actions after constraints – To be included in test case file
  • 38. © 2019 Magento, Inc. Page | 38 Questions ?
  • 39. © 2019 Magento, Inc. Page | 39 Thank You