have you ever written your code and when you are fixing one bug there is a new
bug arises so that's the point you need code testing so let's see what exactly
code testing is and why we need it actually everybody test it doesn't
matter if you're writing the code for testing purpose or not you test suppose
you create a form then you will test by just going to browser you open the
browser and if you see that form on the browser you will say okay your code you
have written for the form is correct that means you have tested that if you
have a variable then what you do maybe if you want that variable to be
available after four or five lines you will probably do Ver_dump if you are from
PHP world or you will just return that on this function and you will just see
on the console maybe but that particular variable has value after four line or
five line or not so these are we can say our manual testing and humans always
make mistakes so why we write tests because if you are not writing test
you definitely have bug and what means Bug. Bug means the error or any kind of
problem your code will create if you are not writing tests for your codes and it
is extremely important so it will be like if you have written tests for your
code then your program will work otherwise you have to go to the first
point that means no test you have a bug definitely 100% sure if you are not
writing test you have the bug but if you are doing this manually what will be the
result fixing one bug will result at least a new book and I have written here
at least but most probably you we'll find that if you fix one thing it
will change 5 10 20 things and you will like okay but how this effect that thing
because you don't remember how things are linked so that's the important point
because manual testing takes time lot of time so that means if you have a big
project if you are testing it manually retest your entire code is not possible
manually you cannot I'm sure you cannot test whole of your software project
whatever it is manually because there are so so so many features so many
modules so many sections involved that it will take more time then you have
spent on the writing of the code so what if you have some automatic system which
can test on behalf of you that means you just write your code for the first time
and then everything is taken care by the tests just run the tests and everything
is now going to test by your written code that means a code will test another
code so think about this project flies and the project cost will highly depend
upon the tests if you have not written any test for your code then you will see
this graph size and cost in terms of that can be money that can be time that
can be labor or the hard work you have given for your project and the graph
will look like this so what is happening here if your project size is small and
remember you don't have any test for your code so sizes are small the cost is
also small obviously and if you have not written your test then it will be fine
because size is small you can test it manually
many times but as the size of the project will increases the cost
increases why because you know think about this size of project increases
then you you need manual testing because you
don't have any test code written then if you are testing manually
this means surely it will take some time and you know time is money so money is
gone time is gone and obviously that takes hard work to test you need someone
just go feature by feature to test it and if there is a bug then you need to
solve it and again you need to test each and everything so cost will be maximized
so think about this in another way what if you have rewritten the test and what
will be the size and cost effects so again the graph size and cost in terms
of money time and labour and this is the just opposite one if the size of your
project increases and remember you have written the test size of the project
increases then cost will decrease and that's exactly what you want
and cost in terms of money time labor because you have written tests one time
then every time whenever you make changes you just run code you just run
one command and that will figure out where you have problem and exact that
point you can fix that no time for testing everything is taken care by the
software or the testing tool you have and if the size of your project is very
small yes you can write tests but if it is just a simple blog why you need tests
but it's better to write a test for even a smaller project because the project's
may get bigger later so it's better to have a test for smaller the cost will
increase but not this much I think I have to make it like this okay so I
think you get the point so the you will say started I need to
write code twice one for exact code or exact the program I want to write and
second for the code yes you're right but this reduces the deeper
as I am saying you for initial purpose yes it will take some time some more
time to write tests birthday as you progress on your project it will reduce
your deeper time I'm sure I'm extremely sure if you write tests if later you
will proud of yourself and this actually the tests actually avoid human best job
which is mistake and let's see this mistake and obviously if you know that
your program is not going to break you will build confidence and you will say
ok take this project take this app and an extremely sure it will not get break
because I have written test for these codes so this is actually why you write
tests but how you write tests you always test for known input and output and just
a simple tip that whenever you're writing the test just test for known
output suppose you have a test for multiplication so the 2 multiplied by 2
is 4 you know don't don't do like this is that 21 point 2 5 6 multiplied but in
29 point 5 5 5 is what you don't know that yes otherwise you need to get a
calculator but just just make input and output simpler so that you can test
verify and next point is that run faster test first and the slower test you know
some time if you are dealing with the data base test takes long time so that
test if a single test taking 3 or 4 seconds and that test always pass and
you have a bug on the last 50th test which is just a simple routing problem
you need to wait for all that time because you know ok yeah this one is
good but it take time so why not run the first test test first and
the slowest at the last so these are the simple things to introduce you with the
code testing in the next episode we will see what is unit testing and why we need
that and what exactly it is and you can find the link in the description for in
the next video or for the whole series of that testing we will do PHP unit and
then we will go forward with level testing also on the browser testing also
and this series will going to be fun so make sure you subscribe to this channel
and after subscribing don't forgot to hit the bell icon so that you will get
the notification every time I upload a new video don't forgot to like but films
on Facebook Twitter and Instagram we will meet in the next episode till then
good bye