yes I know what is testing but what exactly unit testing is we will see the
answer in this episode so let's start and with that I am your host Sarthak and
this is a channel for web development related things and don't forget to
subscribe and hit bell icon to get the notification if you want to have the
awesome videos related to level angular Vuejs react and much more things so
let's see what we are going to learn here
so unit testing what is unit testing but before that let us see what not is unit
testing so unit testing is not a software flow what that software flow
means it means it's not going to test how the user will use your project your
app or your software it's not like user will be first go to there and then will
he will go to second page and you need to test that a user can go on this way
only not not known this is not a unit testing unit testing is not just for
testing the controller it's not just using control because controller can has
many functions this means controller can has many
functionality and unit tests are not for testing whole of the controller same
unit testing is not for a simple module suppose you have a module which is going
to get the image optimize it then save to database and all these things so this
seems like lots of steps unit testing is not for module so what exactly unit
testing is you know unit means one have you ever seen I want to unit of
something so unit means one so one test for one function simple thing each
method for the test we will write tests as a method so each
method test one thing only you know only one thing so that's why I said that
controller can have many functions so one test for one function because one
function can only do one thing so that's the important part
and in every unit test you probably have one assert because if you have more than
one assert you are asserting or you are expecting two or three output for some
functionality that means you have two or three things you are checking for one
test and that's not a unit test unit test means unit checking only one
functionality at a time or one test for one functionality then unit test has to
be decoupled what that mean yes I know I have written one test that will just
going to check whether there is a user in the database or not then we have
another test which will get one user but these two things has to be separate so
it's not like if you are not running the first test second breaks if you are not
testing the second one first breaks so that has to be covered every test can
individually be tested and obviously on the flow also so test doesn't interfere
each other like I have said that if you are getting a user information for one
function one test then that functionality doesn't has to pass to
other tests each test has its own identity own data own structure nothing
else so this means each unit test doesn't share data with other tests so
this is most important thing you need to take care while testing unit tests so
what is the goal of unit test the goal of unit testing is simple that ensure
that each part of program working fine as an
isolated system getting this point most important part is work as an isolated
system so in that case unit testing is for each
functionality each system and you will write tests so this is all about unit
testing and I'm sure you'll like this episode if you haven't liked this
episode just subscribe to this channel and hit the bell I can so that you will
get the notification every time I upload some other videos related to web
development things and they follow with fumes on Facebook Twitter Instagram
share this video with your developer friends so that everyone know what is
unit testing and we will meet in the next episode where we will start with
PHP unit to see how we can start from scratch with PHP unit to test a simple
thing on our PHP world so we will meet in the next episode till then good bye