From the Testing Pyramid Notes :
1)Unit Tests : It should be the building blocks of the tests. Any method, which is doing something non trivial should be the included as a part of unit Test.These tests should be in the same platform where development is done. Developers should take care of writing these tests, as they know what they have developed.
2)UI Tests : UI tests involves lots of setup and execution. Now what happens is let say I have created one Simple Calculator application, and If i test my Sum functionality from UI, it involves lots of Happenings like we will be testing : whether input parameters are properly shown, Button is clicked , output is shown as desired etc.Now here the problem is very simple : We are coupling Service Testing (Sum functionality) with UI, which is really time consuming, plus UI automation is handling multiple responsibilities, apart from UI[presentation testing] we are also testing services {which is really bad}.Plus it will consume whole lot Of effort and Time, because each time input fields are populated then invoke the Service and then check for desired Output. Instead Of it, Just remove Service Testing from UI automation, In service check for all cases where service can work or broke,
and then For UI just write Automation for Presentation part, to test whether UI is pretty good as per desired and your functionality is working end to end.
3)Service Tests: Where you will tests for services which you are exposing to UI or End Users.
Number Game :
Unit Tests: Since Unit tests are showing whether your code is working in Bits and Pieces.Any method, Class, Module which you find is important and Holding some non Trivial Business Logic, should be the part Of Unit Tests.These Tests should be maximum in Number, because it penetrates all your non important functionality.Quantity of Unit Tests will be much higher since you are covering almost all your Code.So candidates for Unit Testing are much High.
Service Tests : These are the API's or we can say services provided to End User so that they can consume it, Now Candidates for Service Testing are all services which you are exposing to End User to Use Them. So we can say these are not very high but intermediate in number.
UI Tests : Since UI keeps on changing so writing Tests for displays in UI is not much useful and could be Time Consuming, Instead of it UI Testing are good at Testing Navigation Flow and some important Presentation part, So this is the least bothered stuff to Test.
Thats why we have pyramid like structure :
1)On Top is UI[Low Priority, Less Useful, Keeps on Changing no need to put too much effort on That]
2)Then Service Layer [Medium Priority or important priority, since it projects your Business Flow, Again needs to tested thoroughly]
3)Unit Tests[Most important, needs to test your code in Bits and Pieces, plus bugs or any issue can be caught very early, Developers are mostly responsible to write it, to test their own Code].
1)Unit Tests : It should be the building blocks of the tests. Any method, which is doing something non trivial should be the included as a part of unit Test.These tests should be in the same platform where development is done. Developers should take care of writing these tests, as they know what they have developed.
2)UI Tests : UI tests involves lots of setup and execution. Now what happens is let say I have created one Simple Calculator application, and If i test my Sum functionality from UI, it involves lots of Happenings like we will be testing : whether input parameters are properly shown, Button is clicked , output is shown as desired etc.Now here the problem is very simple : We are coupling Service Testing (Sum functionality) with UI, which is really time consuming, plus UI automation is handling multiple responsibilities, apart from UI[presentation testing] we are also testing services {which is really bad}.Plus it will consume whole lot Of effort and Time, because each time input fields are populated then invoke the Service and then check for desired Output. Instead Of it, Just remove Service Testing from UI automation, In service check for all cases where service can work or broke,
and then For UI just write Automation for Presentation part, to test whether UI is pretty good as per desired and your functionality is working end to end.
3)Service Tests: Where you will tests for services which you are exposing to UI or End Users.
Number Game :
Unit Tests: Since Unit tests are showing whether your code is working in Bits and Pieces.Any method, Class, Module which you find is important and Holding some non Trivial Business Logic, should be the part Of Unit Tests.These Tests should be maximum in Number, because it penetrates all your non important functionality.Quantity of Unit Tests will be much higher since you are covering almost all your Code.So candidates for Unit Testing are much High.
Service Tests : These are the API's or we can say services provided to End User so that they can consume it, Now Candidates for Service Testing are all services which you are exposing to End User to Use Them. So we can say these are not very high but intermediate in number.
UI Tests : Since UI keeps on changing so writing Tests for displays in UI is not much useful and could be Time Consuming, Instead of it UI Testing are good at Testing Navigation Flow and some important Presentation part, So this is the least bothered stuff to Test.
Thats why we have pyramid like structure :
1)On Top is UI[Low Priority, Less Useful, Keeps on Changing no need to put too much effort on That]
2)Then Service Layer [Medium Priority or important priority, since it projects your Business Flow, Again needs to tested thoroughly]
3)Unit Tests[Most important, needs to test your code in Bits and Pieces, plus bugs or any issue can be caught very early, Developers are mostly responsible to write it, to test their own Code].