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 ... 
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

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 ... 
58m 55s
Jun 2013
EP14 - Agile Software Development
‏الحلقة الرابعة عشر من راديو اسأل مطور, في هذه الحلقة نناقش موضوع الطرق الهندسية الحديثة في ادارة المشاريع البرمجية, و كيف تقدم هذه الطرق داخل بيئة عملك و ما هي الفوائد و التحديات التي يمكن تواجهها. Welcome to the 14th episode of Ask Developer Podcast, in this episode we discuss ... 
1h 19m
Jun 2013
EP15 - Developer Skills - Debugging
tail spinning
29m 1s
Nov 2021
Essam Cafe: Conversation with Kent Beck
‏Video for the episode: https://www.youtube.com/watch?v=x_n7IOCKC9c Topics we are hoping to cover in this episode: - People over process - Complexity introduced by software management - Relentless Refactoring - Thoughts on "Test Driven Development" after 20 years - Experience at ... 
1h 4m
Oct 11
SABBAH_Test02
‏TEST Podcast 
1m 32s
Feb 2021
حلقة تجريبية
‏مجرد حلقة تجريبية نشرح فيها مواصفات الجهاز المناسب للبرمجة 
29s
Mar 2013
EP01 - AskDeveloper PodCast - Software Quality
‏Welcome to the first episode of the AskDeveloper Podcast, in this episode Tamer Zaki & Mohamed Elsherif are discussing the Software Quality issues especially in the Egyptian technology market, and how to change the culture for companies and development teams to adopt the right m ... 
56m 37s
Nov 2020
EPISODE #36: Feet and Butt, a mindfulness exercise. تمرين فالتآمّل
‏Episode Experimental. 
6m 21s
Sep 2021
EPISODE #77: الخدمة
‏In this episode you will hear about: 1- Why taking pride in your work is essential. 2- Types of work. 3- Networking. 4- Applying for a job. 5- First job. 6- Integrating an existing team. 7- Impostor Syndrome. 8- When to quit. Join us on Instagram @kahwaoupodcastdz 
31m 28s