Jeroen Boersma

Magento 2 Testing Frameworks

Jeroen Boersma

Magento 2 Testing Frameworks

Leeuwarden, the Netherlands

Srcode

Magento/PHP backend developer

@JeroenBoersma             @srcoder

Why this talk

I'm pretty bad at remembering everything!

I want to implement Unit tests to be part of my daily routine!

I did a few, but still need to do more!

 

Everyone should do it, starting yesterday! (that includes me)

If you want to put it on the brand new Magento Marketplace, your module needs to have tests!

Magento 1 vs Magento 2

  • few functional tests
  • few unit tests
  • full functional tests
  • full unit tests
  • and more to come

Unit Test

Unit tests - Why use them

If you write something to day, you just want it to last another.

Especially when working with Magento 2(or large codebase in general)

Unit tests - Magento 2

/dev/unit/phpunit.xml.dist

It will run all unit-tests for every module, internally/externally/vendor(framework/module), so you can test the whole Magento 2 scope.

 

composer install --dev (default)

Magento 2 - example

Unit tests in your module

Just add a Test/Unit/*Test.php and Magento will autoMagentely pick them up

Learn writing a Unit Test

  1. Do a exercise with a buddy
  2. Write a minimum test so it breaks and pass it over
  3. Fix the code, return a result so the test turns green
  4. Goto 2

 

Example: Roman number test

Learn writing a Unit Test

Wrap up

  • Start writing those tests...
  • Magento 2 Marketplace requires it
  • It is better for your memory if you write things down

Thanks

Questions?

Meet Magento 16NL - Testing in Magento 2

By Jeroen Boersma

Meet Magento 16NL - Testing in Magento 2

Magento 2 comes with a full deck of testing tools. They should already be part of your daily life! I'll coves a overview and practical preview of some tests you can write and use

  • 2,011