HOME

TheInfoList



OR:

A sanity check or sanity test is a basic test to quickly evaluate whether a claim or the result of a calculation can possibly be true. It is a simple check to see if the produced material is rational (that the material's creator was thinking rationally, applying
sanity Sanity (from la, sāntā) refers to the soundness, rationality, and health of the human mind, as opposed to insanity. A person is sane if they are rational. In modern society, the term has become exclusively synonymous with ''compos mentis'' ( ...
). The point of a sanity test is to rule out certain classes of obviously false results, not to catch every possible error. A
rule-of-thumb In English language, English, the phrase ''rule of thumb'' refers to an approximate method for doing something, based on practical experience rather than theory. This usage of the phrase can be traced back to the 17th century and has been associat ...
or back-of-the-envelope calculation may be checked to perform the test. The advantage of performing an initial sanity test is that of speedily evaluating basic function. In arithmetic, for example, when multiplying by 9, using the divisibility rule for 9 to verify that the sum of digits of the result is divisible by 9 is a sanity test—it will not catch ''every'' multiplication error, however it's a quick and simple method to discover ''many'' possible errors. In computer science, a ''sanity test'' is a very brief run-through of the functionality of a computer program, system, calculation, or other analysis, to assure that part of the system or methodology works roughly as expected. This is often prior to a more exhaustive round of testing.


Mathematical

A sanity test can refer to various orders of magnitude and other simple
rule-of-thumb In English language, English, the phrase ''rule of thumb'' refers to an approximate method for doing something, based on practical experience rather than theory. This usage of the phrase can be traced back to the 17th century and has been associat ...
devices applied to cross-check mathematical calculations. For example: *If one were to attempt to square 738 and calculated 54,464, a quick sanity check could show that this result cannot be true. Consider that yet Since squaring positive integers preserves their inequality, the result cannot be true, and so the calculated result is incorrect. The correct answer, is more than 10 times higher than 54,464. *In multiplication, is not 142,135 since 918 is divisible by three but 142,135 is not (digits add up to 16, not a multiple of three). Also, the product must end in the same digit as the product of end-digits: but 142,135 does not end in "0" like "40", while the correct answer does: An even quicker check is that the product of even and odd numbers is even, whereas 142,135 is odd.


Physical

*The power output of a
car A car or automobile is a motor vehicle with wheels. Most definitions of ''cars'' say that they run primarily on roads, seat one to eight people, have four wheels, and mainly transport people instead of goods. The year 1886 is regarded as ...
cannot be 700 kJ, since the unit ''joules'' is a measure of energy, not power (energy per unit time). This is a basic application of dimensional analysis. *When determining
physical properties A physical property is any property that is measurable, whose value describes a state of a physical system. The changes in the physical properties of a system can be used to describe its changes between momentary states. Physical properties are o ...
, comparing to known or similar substances will often yield insight on whether the result is reasonable. For instance, most metals sink in water, so the density of most metals should be greater than that of water (~). * Fermi estimates will often provide insight on the order of magnitude of an expected value.


Software development

In software development, a sanity test (a form of software testing which offers "quick, broad, and shallow testing") evaluates the result of a subset of application functionality to determine whether it is possible and reasonable to proceed with further testing of the entire application. Sanity tests may sometimes be used interchangeably with smoke tests insofar as both terms denote tests which determine whether it is ''possible'' and ''reasonable'' to continue testing further. On the other hand, a distinction is sometimes made that a smoke test is a non-exhaustive test that ascertains whether the most crucial functions of a programme work before proceeding with further testing whereas a sanity test refers to whether specific functionality such as a particular bug fix works as expected without testing the wider functionality of the software. In other words, a sanity test determines whether the intended result of a code change works correctly while a smoke test ensures that nothing else important was broken in the process. Sanity testing and smoke testing avoid wasting time and effort by quickly determining whether an application is too flawed to merit more rigorous QA testing, but needs more developer
debugging In computer programming and software development, debugging is the process of finding and resolving '' bugs'' (defects or problems that prevent correct operation) within computer programs, software, or systems. Debugging tactics can involve in ...
. Groups of sanity tests are often bundled together for automated unit testing of functions, libraries, or applications prior to merging development code into a testing or
trunk Trunk may refer to: Biology * Trunk (anatomy), synonym for torso * Trunk (botany), a tree's central superstructure * Trunk of corpus callosum, in neuroanatomy * Elephant trunk, the proboscis of an elephant Computing * Trunk (software), in rev ...
version control branch, for automated building, or for continuous integration and continuous deployment. Another common usage of ''sanity test'' is to denote checks which are performed programme code, usually on arguments to functions or returns therefrom, to see if the answers can be assumed to be correct. The more complicated the routine, the more important that its response be checked. The trivial case is checking to see whether the
return value In computer programming, a return statement causes execution to leave the current subroutine and resume at the point in the code immediately after the instruction which called the subroutine, known as its return address. The return address is s ...
of a function indicated success or failure, and to therefore cease further processing upon failure. This return value is actually often itself the result of a sanity check. For example, if the function attempted to open, write to, and close a file, a sanity check may be used to ensure that it did not fail on any of these actions—which is a sanity check often ignored by programmers. These kinds of sanity checks may be used during development for debugging purposes and also to aid in troubleshooting software
runtime errors Execution in computer and software engineering is the process by which a computer or virtual machine reads and acts on the instructions of a computer program. Each instruction of a program is a description of a particular action which must be c ...
. For example, in a bank account management application, a sanity check will fail if a withdrawal requests more money than the total account balance rather than allowing the account to go negative (which wouldn't be sane). Another sanity test might be that deposits or purchases correspond to patterns established by historical data—for example, large purchase transactions or ATM withdrawals in foreign locations never before visited by the cardholder may be flagged for confirmation. Sanity checks are also performed upon installation of stable, production software code into a new computing environment to ensure that all dependencies are met, such as a compatible operating system and link libraries. When a computing environment has passed all the sanity checks, it's known as a sane environment for the installation programme to proceed with reasonable expectation of success. A
"Hello, World!" program A "Hello, World!" program is generally a computer program that ignores any input and outputs or displays a message similar to "Hello, World!". A small piece of code in most general-purpose programming languages, this program is used to illustra ...
is often used as a sanity test for a development environment similarly. Rather than a complicated script running a set of unit tests, if this simple programme fails to compile or execute, it proves that the supporting environment likely has a configuration problem that will prevent ''any'' code from compiling or executing. But if "Hello world" executes, then any problems experienced with other programmes likely can be attributed to errors in that application's code rather than the environment.


See also

*
Certifying algorithm In theoretical computer science, a certifying algorithm is an algorithm that outputs, together with a solution to the problem it solves, a proof that the solution is correct. A certifying algorithm is said to be ''efficient'' if the combined runtime ...
* Checksum *
Fermi problem In physics or engineering education, a Fermi problem, Fermi quiz, Fermi question, Fermi estimate, order-of-magnitude problem, order-of-magnitude estimate, or order estimation is an estimation problem designed to teach dimensional analysis or ...
* Mental calculation * Proof of concept


References

{{standard test item Software testing Error detection and correction