Skip to main content

Command Palette

Search for a command to run...

Magento 2 - What is Unit Test?

Updated
1 min read
Magento 2 - What is Unit Test?

Unit Test is the smallest part of testing in Magento 2. Module must has classes and each class must has method(s) on it, that method contains lot of logic, each method return can be null, string, integer, false, etc. So this is where unit test works, we pass conditions and expected returns of passed conditions. for instance:

  1. there is 1 method called getProductBySku($sku), it maybe retuns the product instance or NULL because the SKU doesn't exist.

  2. so we need to create 2 tests for these conditions.


References:

More from this blog

F

Fiko Borizqy (Bestafiko)

51 posts

I wrote these tutorials for myself in future when I forget for the next steps.