π‘ 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
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.
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
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
Telegram
Programming Tips Resources