Sanity testing
From Wikipedia, the free encyclopedia
A sanity test or sanity check is a basic test to quickly evaluate the validity of a claim or calculation. In mathematics, for example, when multiplying by three or nine, that the sum of the digits of the result is a multiple of 3 or 9 respectively is a sanity test.
In computer science it is a very brief run-through of the functionality of a computer program, system, calculation, or other analysis, to assure that the system or methodology works as expected, often prior to a more exhaustive round of testing.
Sanity tests are sometimes mistakenly equated to smoke tests. Where a distinction is made between sanity testing and smoke testing, it's usually in one of two directions. Either sanity testing is a focused but limited form of regression testing – narrow and deep, but cursory; or it's broad and shallow, like a smoke test, but concerned more with the possibility of "insane behavior" such as slowing the entire system to a crawl, or destroying the database, but is not as thorough as a true smoke test.
Generally, a smoke test is scripted (either using a written set of tests or an automated test), whereas a sanity test is usually unscripted.
With the evolution of test methodologies, sanity tests are useful both for initial environment validation and future interactive increments. The process of sanity testing begins with the execution of some online transactions of various modules, batch programs of various modules to see whether the software runs without any hindrance or abnormal termination. This practice can help identify most of the environment related problems. A classic example of this in programming is the hello world program. If a person has just set up a computer and a compiler, a quick sanity test can be performed to see if the compiler actually works: write a program that simply displays the words "hello world".
A sanity test can refer to various order of magnitude and other simple rule of thumb devices applied to cross-check mathematical calculations. For example:
- If one were to evaluate 7382 and came up with the answer 123, a quick sanity check would show this to be wrong since the square of 500, a smaller number to start with, is 250,000, which is greater than the incorrect 53,874.
- In multiplication, 918 x 155 is not 142135 since 918 is divisible by three but 142135 is not (digits do not add up to a multiple of three).
- When talking about quantities in physics, the power output of a car cannot be 700 kJ since that is a unit of energy, not power (energy per unit time).