Fiko Borizqy
Fiko Borizqy

Follow

Fiko Borizqy

Follow

Magento 2: What is Unit Test?

Fiko Borizqy's photo
Fiko Borizqy
·Jan 8, 2023·

1 min read

Magento 2: What is Unit Test?

Photo by Rubaitul Azad on Unsplash

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:

 
Share this