After receiving a Software build with the minor issues fixes in code or functionality, Sanity testing is carried out to check whether the bugs reported in the previous build are fixed & there is a regression introduced due to these fixes i.e. not breaking any previously working functionality. The main aim of Sanity testing to check the planned functionality is working as expected. Instead of doing whole regression testing the Sanity testing is performed.
Sanity tests help to avoid wasting time and cost involved in testing if the build is failed. The tester should reject the build upon build failure.
After completion of regression testing, the Sanity testing is started to check the defect fixes & changes done in the software application is not breaking the core functionality of the software. Typically this is done near the end of SDLC i.e. while releasing the software. You can say that sanity testing is a subset of acceptance testing. We can also say Tester Acceptance Testing for Sanity testing. Sanity testing is a narrow & deep approach to testing, it needs to concentrate limited & main features of testing in detailed.