logo
episode-header-image
Apr 2020
1 h

Episode[14]: Unit Testing 101

محمد لؤي وأحمد الألفي
About this episode

Because of the high complexity and depth of this episode, we will share with you the episode outline and the topics discussed here as a reference.

Episode Outline:

What is unit testing?

test for the smallest possible pieces of your program.

كل حاجة فيها سليمة بس لوحدها - سلطان السكري

Why Unit Testing

  1. Help the developer deeper understand the logic he/she is implementing.
  2. Help developer writes more modular, loosely coupled code.
  3. Make it faster to develop and debug. (You can fake all the possible scenarios and see how the test is responding to each)
  4. Find bugs early.
  5. Help with documenting the code you are doing.
  6. Help when it comes to refactoring.
  7. It helps to automate the development process and decrease deployment-related friction.

Unit Testing Best Practices

1- Identifying Units:

When it comes to the unit you are testing, you need to answer three questions.

a. What is the output of this unit?

b. What helper functions that this unit is using to achieve that output?

c. Are there any side effects resulting from this unit. (it modifies state variables outside its scope).

2- Naming & Description

Why? it makes the test easier to read and hence easier to figure out what went wrong.

Describe & It. (This thing / should or does something)

- The search function should return an array of strings matching the search keyword.

- The search function should return an empty array when a keyword is not matching any.

- throw an exception if the keyword is an empty string.

3- Mocking & Stubs

- The unit test is 50% mocking and 50% clean code.

  • Check Martin Fowler's article in the for more depth in mocking 

Check the resources section.

 

References:

Episode Picks:

Up next
Jun 2023
Episode[60]: NLP, Chatbots, ChatGPT & Beyond
‏ResourcesStanford's CS224N: Natural Language Processing with Deep Learning [Course Link, Youtube Lectures]Wit.aiDialogflowThe bAbI projectKey-Value Memory Networks for Directly Reading DocumentsProlog Episode Picks:Alfy: Front End Happy Hour: PatentsMicrofrontend.devLuay:The Dip ... Show More
1h 24m
May 2023
Episode[59]: Layoffs, ChatGPT, AI, ...etc
‏Episode Picks:Alfy: HoN Revival - GitHubThe Stack Overflow Podcast Luay:Huberman Lab Podcast 
1h 4m
Mar 2022
Episode[58]: Monorepos
‏Episode ResourcesNX Technology Radar (Trail)Semaphore Podcast Episode: Monorepo and Micro-Frontends with Jonathan Creamernx.devNestJsEpisode Picks:Alfy:5K PlayerLuay:Storytel 3 months subscriptionCrash Landing on You 
35m 45s
Recommended Episodes
Mar 2013
EP02 - AskDeveloper Podcast - Software Quality (Contd)
‏Welcome to the second episode of the AskDeveloper podcast, in this episode we are excited to announce a new host (Ahmed ElMalt) who joined us this week to give us his perspective and experience with software quality. This week, the hosts are discussing in more details the subjec ... Show More
58m 55s
Jun 1
From Narcissism to Empathy - Joanna Saoud
‏She had it all — beauty, confidence, and control. But behind the manipulation, toxic relationships, and wild nights was a heart that couldn’t feel…Until one unexpected night, everything changed.This is her raw, unfiltered journey — one you’ll feel deep in your soul.A testimony o ... Show More
39m 27s
May 2020
ق
‏ق 
9m 36s
May 2020
عبس
‏عبس 
3m 10s
Apr 2025
ريفيو #6...نص الشعب إسمة محمد
‏https://linktr.ee/FenganWqahwa 
3m 22s
May 2020
الجن
‏الجن 
5m 2s
Mar 2025
ريفيو #5... مسلسل النص
‏https://linktr.ee/FenganWqahwa 
2m 53s
Mar 2025
سورة الإنسان | ماهر المعيقلي
‏⁠موقع ⁠الطريق إلي القرآن⁠⁠ 
4m 57s