tags:

views:

90

answers:

5

What is it and why is it used/useful?

+2  A: 

A sanity test or sanity check is a basic test to quickly evaluate whether a claim or the result of a calculation can possibly be true @ http://en.wikipedia.org/wiki/Sanity_testing

Pangea
yes, but what does it all MEAN Watson?
whydna
If, for example, you are calculating a square root by an iterative mechanism. You would then expect that the root you find is positive, and when multiplied by itself it approximately equal the input value. So you might add a couple of checks to ensure your logic is correct - that the answer is 'sane'. These are sanity checks - they cannot be false if the algorithm is logically consistent.
Pete Kirkham
A: 

Good example is a sanity check for a database connection.

SELECT 1 FROM DUAL

It's a simple query to test the connection, see:

http://stackoverflow.com/questions/917927/select-1-from-dual-mysql

It doesn't test deep functionality, only that the connection is ok to proceed with.

Jon
thanks. But how is this different then a smoke test?
whydna
A database sanity check might form part of a smoke test, but generally a smoke test is a set of rudimentary checks that you would run to ensure an application is working correctly.
Jon
More info here - http://stackoverflow.com/questions/745192/what-is-a-smoke-testing-and-what-will-it-do-for-me
Jon
A: 

It is a basic test to make sure that something is simply working.

For example: connecting to a database. Or pinging a website/server to see if it is up or down.

Bryan Denny
No, it is not. Neither of those check whether the logic of the system is 'sane', they both check whether the network is OK. So unless you are proposing that you are performing a sanity check on the principles of TCP itself (which are fairly well attested to be sane), pinging something is not a sanity check. And even then, it fails the basis of a sanity check - that if the logic is correct, the test cannot fail, whereas the logic of TCP is correct, yet pings can still fail.
Pete Kirkham
Attempting a database connection or seeing if a host is up are much higher level operations than a basic sanity check.
meagar