I don't write tests for my code if this is the answer you will give when someone
asks you do you write tests for your code then this video is absolutely for
you in this video I'm going to explain you 4 excuses for not writing the test
and 8 benefits of writing the test so after this video I am sure I can
convince you from giving excuses for not writing the test to be excited to write
the test so let's jump to the first excuse test eat up my time writing test
is a time-consuming process okay so think about this there's a surgeon and
the surgeon says okay I'm a good surgeon and I know how to operate I don't waste
my time cleaning the surgical tooths really is this you want no so yes test
takes some time but it's an important step to be followed without test you
can't write best software similar to this that without cleaning the tools
surgeon must not operate tests build up confidence and improve your work process
second excuse generally people give that code is hard to test I'm not sure how to
test this code so again think about this you have an appointment with your doctor
and doctor says I can't diagnose you it's very hard I'm doctor I know many
diseases let's start let's try with headache pill really try no no you you
don't want this feeling to be occur on your client so better code is testable
and if your code is not testable your code is junk sorry to say but your code
is Junk, code has no standard writing test makes you actually force you to write a
code with a standard. Next excuse generally people give is project
deadline is so close client is pushing us I need to finish this as soon as
possible so I can think about another scenario there is a chef
and he says that okay guests are hungry I have not tasted the food but I know
how to cook and it should be tasty really should be no so completing
project with the bug come back with a bang because client will not get
satisfied and because of this you may lose a next big opportunity from the
same client then next excuse is I write bug free code an experienced person I
know how to write correct and bug-free code if this is your point sorry to say
you are not a good developer. Developer are humans and human commit mistakes and
if you're not sure what you have written 100% work then you are not a good
developer. Think about this that do you want to live in a building whose
engineer is saying that I don't know the lifespan of this building if any wall
break we will fix it for free later no no we don't want this, similarly your
client don't want this to be happened so now let's work on why testing is
essential so the first point is when you are writing your tests you can find
problems early or easily also writing a test before writing actual code provides
you a failing test and then that tests forces you to write a correct bug-free
code. So this is the benefit number one for writing the test then easier to make
changes once you have written a valid code with a valid test you can easily
make changes because every if anything goes wrong test will going to tell you
that you are doing something wrong just correct it third is that bug appear when
to feature interact suppose there are two simpler simpler code and you have
not written actual test for them you say that okay these are correct I know
what's the point of writing test but you know maybe later
these two functionalities come together and create a feature and then provide
error so with the test you can create complex features with a confidence also
test give you faster feedback instant feedback is given by the test because
you have written the test that test is failing because of some error and that
error is occurring and you know error you can easily solve it so there is a
faster feedback system and by doing this if code works you get confidence if not
you work on the error given by the test so it's a very fast system next is long
terms time-saving writing test for every possible bug occur every time a bug
occur every time a problem occur you write a test to overcome that problem
and slowly slowly your project is becoming more and more bug free so think
about that as you are growing with the tests you are less spending time on your
project because everything is testable you know everything is working absolutely
fine next is test creates documentation for
your project for every big project with a lot of features it's difficult to keep
track of everything because a big project can be handled by many
developers so a test directory tells you what your project what your software is
capable of doing every test describes its functionality so that's the benefit
of writing the test next is continuous integration if you are not familiar with
continuous integration this allow only working code to be go into the
production that means if something doesn't work if your tests fail you're
you're good or your software doesn't go into the production and this is the
power of test by using the continuous integration there are lots of continuous
integration CI tools available online and you can have the benefit bird when
you write the tests and last but not the least most important is contribute to
open source you know open source projects are
the future to contribute to them you must prove that you're good or your
feature is working absolutely fine and along with that it doesn't affect the
project native feature and you can prove this by writing a test for your code
tests are the proof of good work so if you want to contribute to open source
you must learn how to test so these are the things which are essential for
writing the test and you should know them you should know the benefits of
writing the test so next time if someone says that hey do you write test
either you will say yes if you are doing or you will say I'm learning and I know
the benefits of testing and one thing more if you want to learn more advanced
stuffs and work on real project then head over to bid fumes comm slash
courses section where you will have all the udemy YouTube courses and some of
the premium courses for this website and you can unlock them just by subscribing
to this website with the minimum amount so that you can have all the videos
which are ad free hello hi free that means pure learning so we will meet in
some other video till then good bye