SlideShare a Scribd company logo
1 of 38
© 2017 Magento, Inc. Page | 1 ‘17
Automated tests in Magento
© 2017 Magento, Inc. Page | 2 ‘17
Software Engineer at Magento
Ievgen Sentiabov
© 2017 Magento, Inc. Page | 3 ‘17
The tests pyramid in Magento
© 2017 Magento, Inc. Page | 4 ‘17
© 2017 Magento, Inc. Page | 5 ‘17
Why we need tests?
• Never be sure that everything work
• Show how bad architecture
• Facilitate refactoring
• Show how system works
• Tests as documentation
© 2017 Magento, Inc. Page | 6
Unit Tests
© 2017 Magento, Inc. Page | 7 ‘17
Example #1
© 2017 Magento, Inc. Page | 8 ‘17
© 2017 Magento, Inc. Page | 9 ‘17
© 2017 Magento, Inc. Page | 10 ‘17
© 2017 Magento, Inc. Page | 11 ‘17
Example #2
© 2017 Magento, Inc. Page | 12 ‘17
Unit test types
https://martinfowler.com/bliki/UnitTest.html
© 2017 Magento, Inc. Page | 13 ‘17
© 2017 Magento, Inc. Page | 14 ‘17
Mocking...
© 2017 Magento, Inc. Page | 15 ‘17
Testing class dependency
© 2017 Magento, Inc. Page | 16 ‘17
Or not???
© 2017 Magento, Inc. Page | 17 ‘17
BUT
2 Units and 0 Integration
© 2017 Magento, Inc. Page | 18 ‘17
Are unit tests useless?
• Describe unit behavior
• Early show code smells
• Code coverage shows corner cases
© 2017 Magento, Inc. Page | 19
Integration Tests
© 2017 Magento, Inc. Page | 20 ‘17
Unit vs. Integration
© 2017 Magento, Inc. Page | 21 ‘17
Benefits of Integration Tests
• Verifying interaction between components
• Catch errors between interfaces
• Show "real" components usage
• Check store dependent configurations
• Based on a system specification
© 2017 Magento, Inc. Page | 22 ‘17
Different Approaches
© 2017 Magento, Inc. Page | 23 ‘17
Does TDD work?
© 2017 Magento, Inc. Page | 24 ‘17
Pitfalls
• Interaction with 3rd party systems
• Complicated fixtures
• Fixtures without rollbacks
© 2017 Magento, Inc. Page | 25 ‘17
Solutions
• Mocking
• Atomic fixtures
• Annotations
@magentoAppIsolation
@magentoDbIsolation
@magentoAppArea
© 2017 Magento, Inc. Page | 26
WEB API
Functional Tests
© 2017 Magento, Inc. Page | 27 ‘17
© 2017 Magento, Inc. Page | 28 ‘17
© 2017 Magento, Inc. Page | 29
Functional Tests
© 2017 Magento, Inc. Page | 30 ‘17
© 2017 Magento, Inc. Page | 31 ‘17
Disadvantages
• Expensive "cost"
• Very slow
• Hard to debug
BUT
• Cover whole system
• Can be used for 3rd party integrations
• Imitate real customer's behavior
© 2017 Magento, Inc. Page | 32
Best Practices
© 2017 Magento, Inc. Page | 33 ‘17
Code coverage
© 2017 Magento, Inc. Page | 34 ‘17
Atomic fixtures
Quote
Items
Address
Payment
Items
Address
Payment
Quote
© 2017 Magento, Inc. Page | 35 ‘17
Clean the state
© 2017 Magento, Inc. Page | 36 ‘17
In general...
• Choose testing strategy
• Write rollbacks for fixtures (WEB API Functional)
• Minimum assertions per test
• Avoid loops and conditions in tests
• Test public code
• Cover corner cases
© 2017 Magento, Inc. Page | 37
In the end
© 2017 Magento, Inc. Page | 38 ‘17
Summary
• Writing effective tests is hard
• Tests help find possible bugs earlier
• Improve an architecture
• Allow refactor code safely
• Can be used as system documentation

More Related Content

What's hot

CodeClinic-JavaScript_CertificateOfCompletion
CodeClinic-JavaScript_CertificateOfCompletionCodeClinic-JavaScript_CertificateOfCompletion
CodeClinic-JavaScript_CertificateOfCompletionSandip Das
 
Sharmila Telematics
Sharmila TelematicsSharmila Telematics
Sharmila Telematicsramugus
 
How google crush Quality Assurance
How google crush Quality AssuranceHow google crush Quality Assurance
How google crush Quality AssuranceMadurangaDeSilva1
 
Goobi UK user meeting: TaskManager: processing data under load
Goobi UK user meeting: TaskManager: processing data under loadGoobi UK user meeting: TaskManager: processing data under load
Goobi UK user meeting: TaskManager: processing data under loadintranda GmbH
 
SeleniumCamp 2020 - Shift Right and Observability
SeleniumCamp 2020 - Shift Right and ObservabilitySeleniumCamp 2020 - Shift Right and Observability
SeleniumCamp 2020 - Shift Right and ObservabilityMarcus Merrell
 
Agile QA: 7 Tips for Team Success
Agile QA: 7 Tips for Team SuccessAgile QA: 7 Tips for Team Success
Agile QA: 7 Tips for Team SuccessQASource
 

What's hot (7)

CodeClinic-JavaScript_CertificateOfCompletion
CodeClinic-JavaScript_CertificateOfCompletionCodeClinic-JavaScript_CertificateOfCompletion
CodeClinic-JavaScript_CertificateOfCompletion
 
Sharmila Telematics
Sharmila TelematicsSharmila Telematics
Sharmila Telematics
 
How google crush Quality Assurance
How google crush Quality AssuranceHow google crush Quality Assurance
How google crush Quality Assurance
 
Goobi UK user meeting: TaskManager: processing data under load
Goobi UK user meeting: TaskManager: processing data under loadGoobi UK user meeting: TaskManager: processing data under load
Goobi UK user meeting: TaskManager: processing data under load
 
CodeVigil
CodeVigilCodeVigil
CodeVigil
 
SeleniumCamp 2020 - Shift Right and Observability
SeleniumCamp 2020 - Shift Right and ObservabilitySeleniumCamp 2020 - Shift Right and Observability
SeleniumCamp 2020 - Shift Right and Observability
 
Agile QA: 7 Tips for Team Success
Agile QA: 7 Tips for Team SuccessAgile QA: 7 Tips for Team Success
Agile QA: 7 Tips for Team Success
 

Similar to Automated tests in Magento

Chernivtsi Magento Meetup&Contribution day. Miniailo.I.
Chernivtsi Magento Meetup&Contribution day. Miniailo.I. Chernivtsi Magento Meetup&Contribution day. Miniailo.I.
Chernivtsi Magento Meetup&Contribution day. Miniailo.I. Elogic Magento Development
 
MageConf 2017, Design API Best Practices
MageConf 2017, Design API Best PracticesMageConf 2017, Design API Best Practices
MageConf 2017, Design API Best PracticesIgor Miniailo
 
Chernivtsi Magento Meetup&Contribution day. Naida V.
Chernivtsi Magento Meetup&Contribution day. Naida V.Chernivtsi Magento Meetup&Contribution day. Naida V.
Chernivtsi Magento Meetup&Contribution day. Naida V.Elogic Magento Development
 
Testing in Magento 2
Testing in Magento 2 Testing in Magento 2
Testing in Magento 2 Igor Miniailo
 
Igor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesIgor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesAtwix
 
Mli 2017 technical backward compatibility
Mli 2017 technical backward compatibilityMli 2017 technical backward compatibility
Mli 2017 technical backward compatibilityHanoi MagentoMeetup
 
Max Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMax Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMeet Magento Italy
 
Mli 2017 technical first steps to building secure Magento extensions
Mli 2017 technical first steps to building secure Magento extensionsMli 2017 technical first steps to building secure Magento extensions
Mli 2017 technical first steps to building secure Magento extensionsHanoi MagentoMeetup
 
Monitoring your cache effectiveness in Magento 2
Monitoring your cache effectiveness in Magento 2Monitoring your cache effectiveness in Magento 2
Monitoring your cache effectiveness in Magento 2Tony Brown
 
Magento Cloud - Introduction
Magento Cloud - IntroductionMagento Cloud - Introduction
Magento Cloud - IntroductionOleg Posyniak
 
Magento2.3 API Functional Testing
Magento2.3 API Functional TestingMagento2.3 API Functional Testing
Magento2.3 API Functional TestingVishwas Bhatnagar
 
Multi Source Inventory (MSI) in Magento 2
Multi Source Inventory (MSI) in Magento 2 Multi Source Inventory (MSI) in Magento 2
Multi Source Inventory (MSI) in Magento 2 Igor Miniailo
 
Mli 2017 technical m2 developer experience
Mli 2017 technical m2 developer experienceMli 2017 technical m2 developer experience
Mli 2017 technical m2 developer experienceHanoi MagentoMeetup
 
Magento 2 Best Practice MLUK17
Magento 2 Best Practice MLUK17Magento 2 Best Practice MLUK17
Magento 2 Best Practice MLUK17Brent W Peterson
 
Valeriy Nayda - Best Practices in Magento 2. Based on Multi Source Inventory ...
Valeriy Nayda - Best Practices in Magento 2. Based on Multi Source Inventory ...Valeriy Nayda - Best Practices in Magento 2. Based on Multi Source Inventory ...
Valeriy Nayda - Best Practices in Magento 2. Based on Multi Source Inventory ...Atwix
 
How I ended up touching Magento core
How I ended up touching Magento coreHow I ended up touching Magento core
How I ended up touching Magento coreAlessandro Ronchi
 
Volodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformVolodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformMeet Magento Italy
 
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZBackward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZIgor Miniailo
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhubMagento Dev
 
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
 

Similar to Automated tests in Magento (20)

Chernivtsi Magento Meetup&Contribution day. Miniailo.I.
Chernivtsi Magento Meetup&Contribution day. Miniailo.I. Chernivtsi Magento Meetup&Contribution day. Miniailo.I.
Chernivtsi Magento Meetup&Contribution day. Miniailo.I.
 
MageConf 2017, Design API Best Practices
MageConf 2017, Design API Best PracticesMageConf 2017, Design API Best Practices
MageConf 2017, Design API Best Practices
 
Chernivtsi Magento Meetup&Contribution day. Naida V.
Chernivtsi Magento Meetup&Contribution day. Naida V.Chernivtsi Magento Meetup&Contribution day. Naida V.
Chernivtsi Magento Meetup&Contribution day. Naida V.
 
Testing in Magento 2
Testing in Magento 2 Testing in Magento 2
Testing in Magento 2
 
Igor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesIgor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best Practices
 
Mli 2017 technical backward compatibility
Mli 2017 technical backward compatibilityMli 2017 technical backward compatibility
Mli 2017 technical backward compatibility
 
Max Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMax Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & Quality
 
Mli 2017 technical first steps to building secure Magento extensions
Mli 2017 technical first steps to building secure Magento extensionsMli 2017 technical first steps to building secure Magento extensions
Mli 2017 technical first steps to building secure Magento extensions
 
Monitoring your cache effectiveness in Magento 2
Monitoring your cache effectiveness in Magento 2Monitoring your cache effectiveness in Magento 2
Monitoring your cache effectiveness in Magento 2
 
Magento Cloud - Introduction
Magento Cloud - IntroductionMagento Cloud - Introduction
Magento Cloud - Introduction
 
Magento2.3 API Functional Testing
Magento2.3 API Functional TestingMagento2.3 API Functional Testing
Magento2.3 API Functional Testing
 
Multi Source Inventory (MSI) in Magento 2
Multi Source Inventory (MSI) in Magento 2 Multi Source Inventory (MSI) in Magento 2
Multi Source Inventory (MSI) in Magento 2
 
Mli 2017 technical m2 developer experience
Mli 2017 technical m2 developer experienceMli 2017 technical m2 developer experience
Mli 2017 technical m2 developer experience
 
Magento 2 Best Practice MLUK17
Magento 2 Best Practice MLUK17Magento 2 Best Practice MLUK17
Magento 2 Best Practice MLUK17
 
Valeriy Nayda - Best Practices in Magento 2. Based on Multi Source Inventory ...
Valeriy Nayda - Best Practices in Magento 2. Based on Multi Source Inventory ...Valeriy Nayda - Best Practices in Magento 2. Based on Multi Source Inventory ...
Valeriy Nayda - Best Practices in Magento 2. Based on Multi Source Inventory ...
 
How I ended up touching Magento core
How I ended up touching Magento coreHow I ended up touching Magento core
How I ended up touching Magento core
 
Volodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformVolodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design Platform
 
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZBackward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhub
 
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
 

Recently uploaded

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Automated tests in Magento

  • 1. © 2017 Magento, Inc. Page | 1 ‘17 Automated tests in Magento
  • 2. © 2017 Magento, Inc. Page | 2 ‘17 Software Engineer at Magento Ievgen Sentiabov
  • 3. © 2017 Magento, Inc. Page | 3 ‘17 The tests pyramid in Magento
  • 4. © 2017 Magento, Inc. Page | 4 ‘17
  • 5. © 2017 Magento, Inc. Page | 5 ‘17 Why we need tests? • Never be sure that everything work • Show how bad architecture • Facilitate refactoring • Show how system works • Tests as documentation
  • 6. © 2017 Magento, Inc. Page | 6 Unit Tests
  • 7. © 2017 Magento, Inc. Page | 7 ‘17 Example #1
  • 8. © 2017 Magento, Inc. Page | 8 ‘17
  • 9. © 2017 Magento, Inc. Page | 9 ‘17
  • 10. © 2017 Magento, Inc. Page | 10 ‘17
  • 11. © 2017 Magento, Inc. Page | 11 ‘17 Example #2
  • 12. © 2017 Magento, Inc. Page | 12 ‘17 Unit test types https://martinfowler.com/bliki/UnitTest.html
  • 13. © 2017 Magento, Inc. Page | 13 ‘17
  • 14. © 2017 Magento, Inc. Page | 14 ‘17 Mocking...
  • 15. © 2017 Magento, Inc. Page | 15 ‘17 Testing class dependency
  • 16. © 2017 Magento, Inc. Page | 16 ‘17 Or not???
  • 17. © 2017 Magento, Inc. Page | 17 ‘17 BUT 2 Units and 0 Integration
  • 18. © 2017 Magento, Inc. Page | 18 ‘17 Are unit tests useless? • Describe unit behavior • Early show code smells • Code coverage shows corner cases
  • 19. © 2017 Magento, Inc. Page | 19 Integration Tests
  • 20. © 2017 Magento, Inc. Page | 20 ‘17 Unit vs. Integration
  • 21. © 2017 Magento, Inc. Page | 21 ‘17 Benefits of Integration Tests • Verifying interaction between components • Catch errors between interfaces • Show "real" components usage • Check store dependent configurations • Based on a system specification
  • 22. © 2017 Magento, Inc. Page | 22 ‘17 Different Approaches
  • 23. © 2017 Magento, Inc. Page | 23 ‘17 Does TDD work?
  • 24. © 2017 Magento, Inc. Page | 24 ‘17 Pitfalls • Interaction with 3rd party systems • Complicated fixtures • Fixtures without rollbacks
  • 25. © 2017 Magento, Inc. Page | 25 ‘17 Solutions • Mocking • Atomic fixtures • Annotations @magentoAppIsolation @magentoDbIsolation @magentoAppArea
  • 26. © 2017 Magento, Inc. Page | 26 WEB API Functional Tests
  • 27. © 2017 Magento, Inc. Page | 27 ‘17
  • 28. © 2017 Magento, Inc. Page | 28 ‘17
  • 29. © 2017 Magento, Inc. Page | 29 Functional Tests
  • 30. © 2017 Magento, Inc. Page | 30 ‘17
  • 31. © 2017 Magento, Inc. Page | 31 ‘17 Disadvantages • Expensive "cost" • Very slow • Hard to debug BUT • Cover whole system • Can be used for 3rd party integrations • Imitate real customer's behavior
  • 32. © 2017 Magento, Inc. Page | 32 Best Practices
  • 33. © 2017 Magento, Inc. Page | 33 ‘17 Code coverage
  • 34. © 2017 Magento, Inc. Page | 34 ‘17 Atomic fixtures Quote Items Address Payment Items Address Payment Quote
  • 35. © 2017 Magento, Inc. Page | 35 ‘17 Clean the state
  • 36. © 2017 Magento, Inc. Page | 36 ‘17 In general... • Choose testing strategy • Write rollbacks for fixtures (WEB API Functional) • Minimum assertions per test • Avoid loops and conditions in tests • Test public code • Cover corner cases
  • 37. © 2017 Magento, Inc. Page | 37 In the end
  • 38. © 2017 Magento, Inc. Page | 38 ‘17 Summary • Writing effective tests is hard • Tests help find possible bugs earlier • Improve an architecture • Allow refactor code safely • Can be used as system documentation