Your SlideShare is downloading. ×
Magento Testing - London Magento User Group, December Meetup
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Magento Testing - London Magento User Group, December Meetup

5,548
views

Published on

My presentation about Magento Testing, 4th of December 2013, London Magento User Group, December Meetup. …

My presentation about Magento Testing, 4th of December 2013, London Magento User Group, December Meetup.

You can test any aspect of Magento. Having a continuous integration process in place and test coverage will give your development team confidence to release new functionality even on a Friday afternoon.


Florinel is currently co-founder and Chief Service Officer at Elastera (http://www.elastera.com), a cloud-based Platform as a Service for Magento e-commerce sites.

Published in: Technology

0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,548
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
16
Comments
0
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Testing Magento Florinel Chis @florinelchis London Magento User Group – December Meetup
  • 2. whoami Co-Founder and Chief Service Officer - Development Lead at Warner Music - 11 years in e-commerce - Magento since 2008
  • 3. Magento Testing • Unit Testing – Tools – EcomDev_PHPUnit • Functional Testing (CasperJS) • Performance Testing – Web page performance testing – XHProf, Aoe_Profiler • Resources
  • 4. Unit Testing • Available tools: – plain phpunit – MTAF – EcomDev_PHPUnit – TechDivision_MagentoUnitTesting – Mage-Test
  • 5. Plain phpunit • Test API calls • Test libraries • Other basic tests • Any other aspect of Magento that is not dependent on things like session • Requires lots of effort in “setUp()”
  • 6. EcomDev_PHPUnit • Integrated with Magento • Supports Fixtures • You can test pretty much any aspect of Magento (Controllers, Models, Layout, Config, etc)
  • 7. Database settings • app/etc/local.xml.phpunit <phpunit> <allow_same_db>?</allow_same_db> </phpunit> • 0 – Requires a separate db for the tests • 1 – You can use the same db that Magento uses (local.xml) Note: Fixtures will delete all existing records (@see ::apply() function in Fixture/Processor/*)
  • 8. Module Structure #Namespace/Module/etc/config.xml <phpunit> <suite> <modules> <Namespace_Module /> </modules> </suite> </phpunit> #Test files: Namespace/Module/Test/PathTo/Class.php Namespace/Module/Test/fixtures/*.yaml Namespace/Module/Test/expectations/*.yaml Namespace/Module/Test/providers/*.yaml
  • 9. Testing Emails • Extend Mage_Core_Model_Email_Template • Mailcatcher.me (+API)
  • 10. Mage_Core_Model_Email_Template Mage::getConfig()->setNode( 'global/models/core/rewrite/email_template', 'Namespace_Test_Model_Email_Template' ); // This is a hack to get the runtime config changes to take effect Mage::getModel('core/email_template'); $mailTemplate = Mage::getModel('core/email_template'); //… do your stuff Note: https://github.com/MageTest/Mage-Test is the inspiration for this approach
  • 11. Mailcatcher configuration $ gem install mailcatcher $ mailcatcher php.ini: sendmail_path = /usr/bin/env catchmail -f mail@example.com #REST API: /messages /messages/1.plain /messages/1.json
  • 12. Mailcatcher
  • 13. CI Integration • jenkins-php.org • Book: Integrating PHP Projects with Jenkins by Sebastian Bergmann
  • 14. Examples • Unit Test Demo
  • 15. Functional Testing with CasperJS “CasperJS is an open source navigation scripting & testing utility” • Writtern for PhantomJS or SlimerJS • Good for “writing functional test suites, saving results as JUnit XML” • Other cool features: take screenshots, test remote DOM, scrape web documents
  • 16. ‘No more CAPTCHAs, end robot discrimination’
  • 17. Why CasperJS • Friendly • Javascript • Quick • Simple
  • 18. Performance testing • Web Page – webpagetest.org – PageSpeed – YSlow – other tools • Magento
  • 19. • CI Integration – webpagetest.org API – PhantomJS + YSlow
  • 20. PhantomJS + YSlow phantomjs yslow.js http://yslow.org phantomjs yslow.js -i grade -f xml www.yahoo.com www.cnn.com www.nytimes.com phantomjs yslow.js --info all --format plain --ua "MSIE 9.0" http://yslow.org phantomjs yslow.js -i basic --rulseset yslow1 -d http://yslow.org phantomjs yslow.js -i grade -b http://www.showslow.com/beacon/yslow/ -v yslow.org phantomjs --load-plugins=yes yslow.js -vp 800x600 http://www.yahoo.com phantomjs yslow.js -i grade -f tap -t 85 http://yslow.org
  • 21. CSS Testing • CSSLint • PhantomCSS
  • 22. CSSLint • csslint --warnings=box-model,ids filename.css – [--format=junit-xml | checkstyle-xml]
  • 23. PhantomCSS • https://github.com/Huddle/PhantomCSS
  • 24. PhantomCSS Tips • Avoid dynamic data (homepage menu, banners) • Use version control for the base pictures (and make sure you update them when they should change) • Use the same OS/browser/viewport
  • 25. Magento Performance - XHProf “XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based user interface.” Magento modules: Demac_Xhprof and Liip_Xhprof
  • 26. Aoe_Profiler https://github.com/fbrnc/Aoe_Profiler
  • 27. Where to go from here? • https://github.com/EcomDev/EcomDev_PHPUnit • http://netzarbeiter.com/media/mm13/ • https://github.com/Vinai/test-frameworks-mm13de • https://github.com/lilmuckers/magento-lilmuckers_queue • https://github.com/MageTest • https://github.com/fbrnc/Aoe_Profiler • https://github.com/facebook/xhprof • http://magento.stackexchange.com/ • http://casperjs.org/
  • 28. Questions?
  • 29. Thank you. @florinelchis http://www.linkedin.com/in/chisflorinel