Tutorial :What is unit testing? [duplicate]


I have read dozens and dozens about unit testing, and believe that I have learned through context only what a unit test is, but I want to be sure that I am right. What follows is my understanding of what a unit test is.

Please correct this statement:

"A unit test is a method that provides known arguments to the method being tested, and compares the results of the method being tested to predetermined expected results, and returns success if and only if all results match the expected results, and otherwise returns failure."


This is the MSDN answer:

"The primary goal of unit testing is to take the smallest piece of testable software in the application, isolate it from the remainder of the code, and determine whether it behaves exactly as you expect."

You might find in actuality though that this definition is often stretched and made far more complicated.

It's more interesting to view Unit Testing in relation to other testing disciplines, e.g. Integration Testing, Regression Testing and Manual Testing (test case or test scenario driven). For best results, I believe it's important to use a combination of testing approaches.


Wiki says:

... In computer programming, unit testing is a software verification and validation method where the programmer gains confidence that individual units of source code are fit for use. ...

If you wanna get the real value have a look at http://ayende.com/102/section.aspx/redirect/1 ... here is the beginning only


Conceptually unit testing is important because an ideal set of unit tests will submit multiple, conceivable, comprehensive parameter set assertions (covering both pass and fail conditions) into a code segment at compile time and this will detail oversights / short-comings in submitted source-code modifications.

It's good practice always, but it's mandatory on large-scale applications where a coding error in a small but widely used source segment can effectively break an application. It will not only tell you what routine isn't acting properly, but in what way(s).


As for your specific request:

"A unit test is a compile-time test call assertion into a specific method. Each call typically utilizes parameters to simulate real-world / pass-fail conditions and halts program compilation when an anticipated result doesn't follow from a given test. Idealistically both pass and fail comprehensive conditions are asserted into a given method during each compile after which a code segment was modified."


Is this a homework question? You've given a good concise definition in one paragraph.

Of course you could easily delve deeper into the topic and write pages and pages about unit testing.


I would add "these are automated set of task intended to be ran at regular intervals providing comprehensive coverage of the application."

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »