What is a sanity test/check

天涯浪子 提交于 2019-11-27 09:39:30

问题


What is it and why is it used/useful?


回答1:


A sanity test isn't limited in any way to the context of programming or software engineering. A sanity test is just a casual term to mean that you're testing/confirming/validating something that should follow very clear and simple logic. It's asking someone else to confirm that you are not insane and that what seems to make sense to you also makes sense to them... or did you down way too many energy drinks in the last 4 hours to maintain sanity?

If you're bashing your head on the wall completely at a loss as to why something very simple isn't working... you would ask someone to do a quick sanity test for you. Have them make sure you didn't overlook that semicolon at the end of your for loop the last 15 times you looked it over. Extremely simple example, really shouldn't happen, but sometimes you're too close to something to step back and see the whole. A different perspective sometimes helps to make sure you're not completely insane.




回答2:


Good example is a sanity check for a database connection.

SELECT 1 FROM DUAL

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

SELECT 1 from DUAL: MySQL

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




回答3:


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




回答4:


The difference between smoke and sanity, at least as I understand it, is that smoke test is a quick test to see that after a build the application is good enough for testing. Then, you do a sanity test which would tell you if a particular functional area is good enough that it actually makes sense to proceed with tests on this area.

Example:

Smoke Test: I can launch the application and navigate through all the screens and application does not crash.

-If application crashes or I cannot access all screens, this build has something really wrong, there is "a fire" that needs to be extinguished ASAP and the vesion is not good for testing.

Sanity Test (For Users Management screen): I can get to Users Management screen, create a user and delete it.

  • So, the application passed the Smoke Test, and now I proceed to Sanity Tests for different areas. If I cannot rely on the application to create a user and to delete it, it is worthless to test more advanced functionalities like user expiration, logins, etc... However, if sanity test has passed, I can go on with the test of this area.



回答5:


The basic concept behind a sanity check is making sure that the results of running your code line up with the expected results. Other than being something that gets used far less often than it should, a proper sanity check helps ensure that what you're doing doesn't go completely out of bounds and do something it shouldn't as a result. The most common use for a sanity check is to debug code that's misbehaving, but even a final product can benefit from having a few in place to prevent unwanted bugs from emerging as a result of GIGO (garbage in, garbage out).

Relatedly, never underestimate the ability of your users to do something you didn't expect anyone would actually do. This is a lesson that many programmers never learn, no matter how many times it's taught, and sanity checks are an excellent tool to help you come to terms with it. "I'd never do that" is not a valid excuse for why your code didn't handle a problem, and good sanity checks can help prevent you from ever having to make that excuse.




回答6:


For a software application, a sanity test is a set of many tests that make a software version releasable to the public after the integration of new features and bug fixes. A sanity test means that while many issues could remain, the very critical issues which could for example make someone lose money or data or crash the program, have been fixed. Therefore if no critical issues remain, the version passes sanity test. This is usually the last test done before release.




回答7:


Smoke test is for quick test of a new build for its stability. Sanity test is a test of newly deployed environment.




回答8:


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.




回答9:


The act of checking a piece of code (or anything else, e.g., a Usenet posting) for completely stupid mistakes.

Implies that the check is to make sure the author was sane when it was written;

e.g., if a piece of scientific software relied on a particular formula and was giving unexpected results, one might first look at the nesting of parentheses or the coding of the formula, as a sanity check, before looking at the more complex I/O or data structure manipulation routines, much less the algorithm itself.



来源:https://stackoverflow.com/questions/4055733/what-is-a-sanity-test-check

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!