Saturday, 19 October 2019

Unit testing Java: What is a unit test?

Unit Testing


Unit testing is mainly focus on the smallest element of software design so that it is focused on the modules or software components is divided into different levels. It takes on the smallest element in the software design and try to test on that smallest unit again after that day it is integrated to the main next level module and again they're tested like that. The unit testing is only focus on the smallest element of the software design so it make heavy use of all the main thing is it makes heavy use of white box testing. White box testing mainly focused on the internal structure of the module means testing is completely done on internal structure internal code or structure.


Testing is such a huge important part of web development in general so that is something which we will be focusing on because there's a lot of different types of testing whether that's integration tests, systems testing, stress testing, performance testing all sorts of stuff. Unit testing can be kind of confusing people see the word thrown out a lot like what is unit test right at the end of the day your code is broken up into units right and you might think of these units as maybe like a function or a class or just various different things in your code that do stuff and we're gonna actually go over a specific function in unit tests here in a second and what a unit test does is it essentially just confirms that that bit of code is doing what it's supposed to be doing and unit tests can certainly save your butt along with a host of other styles of testing.




As mentioned unit test tests a specific unit of your code to make sure that it's working you could think of this in a non web development or non coding things as a door right. Unit tests allow you to make changes and updates to your code in all sorts of areas whether that's the implementation of that particular unit or that unit along with other units or whatever it allows you to make changes to your code and have a understanding that it's going to work without having to actually manually check it.

unit testing


Lets understand unit testing with an example, Suppose we have an Asssignment of creating a calculator which can perform operation such as addition, subtraction, division and multiplication. This system i will be dividing into subsystems means the sub modules so rather than working on complete module I divided the module into units a small units so that i ams sure each module or operation is working as expected. Operations is addition is working properly or not subtraction, multiplication is working or not. This testing is known as unit testing where we have divided the end system into units and testing is performed in individual units rather than waiting for the end product and perform the testing at once. This units will be independent of each other so we testing can be performed in units without any dependency of other modules.

0 comments: