Sanity testing is a software testing, which is carried out relatively with the smoke test and the regression test to check whether the functionality or the validity of the functions are still holding the same way before any regression was carried out.
As we have stated earlier, that it cannot be directly assumed or predicted that at which phase the sanity testing is to be carried out, but it is clear that it is done just after the regression testing, as in regression the new functionalities and features are added.
Sometimes, the process of regression and sanity testing is iterated one after another, and so it becomes difficult to figure out which has been done first.
And the concept of smoke testing fully relates with the sanity as well as the regression testing. This may be seen or considered as a very narrow approach, but the depth is really more. It does not discuss many things, but the few things, mainly the quality is sincerely maintained.
Below diagram shows the scope of Sanity Testing :
Concluding, that the main aim of the sanity testing is to assure that the functionality of the software is maintained, even after single or many iterations of regression are carried out.
Suppose, we have different modules like login, add-to-cart, buy, etc in a software. Now in the first module, that is, the log-in mode there are credentials like the username and the password. In the sanity testing, the concern would be whether the module login, is creating a valid user-session for the user.
This session should be created for the user only on fulfilling the criteria for the credentials, that is the username should be valid with at least 2 alphanumerics and the password must a valid.
Now, when the user session is created successfully, then the next main function which is dependent on it is the logout function. So, sanity testing will not go wider in checking with the other modules instead, it would check the functionality of the log out.
Now in case, if the password is invalid, and still the user is able to log inside the user's session then, the software is at heavy risk and this bug must be reported to the development team as soon as possible.
In the software testing industry, many get confused about these three different kinds of testing. One is regression testing, smoke testing, and sanity. It should be made clear, these three are totally different testing, and should not be misunderstood.
Since they are solely interrelated topics, therefore their ideas may get overlapped sometimes. Here are some clarifications about the three different kinds of tests.
Below diagram shows how these three testings are inter-linked.
Therefore, to conclude, about the relation of smoke, sanity and regression tesitng, this can be said that, all are inter-related and one should not get confused with their scope of work.
One test can be carried out earlier and another may be carried out later, based on the scenario, but that does not mean, that they are fully overlapped or not related at all.
In sanity testing, we are concerned about the testing the software, whether after regression and addition or modification of new functionalities also, all the features are safe and nothing has been hampered.
This testing is different from regression testing, in only one sense, that, in regression testing, we are concerned about the functionalities only, but in the sanity testing, all the functional and non-functional requirements and properties of the software is checked again to their validity.
Sanity testing can be seen as a refined version of regression testing.