Programming Tips πŸ’‘
51.5K subscribers
67 photos
10 videos
30 files
354 links
Programming & AI:
Tips πŸ’‘
Articles πŸ“•
Resources πŸ‘Ύ
Design Patterns πŸ’Ž
Software Principles βœ…

πŸ‡³πŸ‡± Contact: @MoienTajik

🎯 Buy ads: https://telega.io/c/ProgrammingTip
Download Telegram
πŸ’‘ Consider the following three laws before writing Unit Test :

1- You may not write production code until you have written a failing unit test.

2- You may not write more of a unit test than is sufficient to fail, and not com-piling is failing.

3- You may not write more production code than is sufficient to pass the currently failing test.

#CleanCode #UnitTest #TDD
What is Unit Testing & Why You Need to Lean It ⁉️

Unit testing is the practice of writing code to test your code and then run those tests in an automated fashion. βœ…

πŸ”ΉπŸ”ΈπŸ”ΉπŸ”Έ

Here is an example. πŸ‘¨πŸ»β€πŸ’»

Imagine you have this function somewhere in your code.
It’s a basic calculate function that takes an input and depending on some conditions, it returns different values.

public float CalculateTax(int input) 
{
if (x) return ...;
if (y) return ...;
return ...;
}


If you want to test this function manually :

1️⃣ You have to run your application
2️⃣ Perhaps you have to login
3️⃣ Maybe do a few clicks here
4️⃣ There to get to a page where this function is used.
5️⃣ You have to fill out a form
6️⃣ Submit it
7️⃣ Verify if this function returned the right result.

And then you have to repeat all these steps, each time using different values in your form. πŸ€¦πŸ»β€β™‚οΈ

πŸ”ΈπŸ”ΉπŸ”ΈπŸ”Ή

Manual testing is expensive πŸ’Έ

As you can see, this is very time-consuming. βŒ›οΈ

This workflow to test this function may take several minutes every time❗️

Now to make matters worse, this is not the only function in your application. 🌍

In a real application, you have tens or hundreds of functions like this ❗️

As your application grows in size and complexity, the time required to manually test all the different bits and pieces increases exponentially. ⏱

So, that’s why we use Automated Testing. ♻️

πŸ”ΊπŸ”ΉπŸ”ΊπŸ”Ή

https://t.me/pgimg/24

[ Full Article ] : http://bit.do/utdd

γ€°γ€°γ€°γ€°γ€°γ€°
#CleanCode #UnitTest #TDD
@ProgrammingTip