Reputation: 3142
I've noticed the features for making tests in Visual Studio 2010 and Netbeans 7 and was wondering what they do exactly. Would using them be more efficient than designing my own tests?
Upvotes: 3
Views: 132
Reputation: 95589
A unit test (as opposed to an integration test) is a test (usually actually multiple tests that happen to exist in the same class and file) that test the functionality of a single unit (typically a class).
An integration test, by contrast, tests the interactions of multiple different units. An end-to-end test is a particular type of integration test that tests an entire software stack, from the UI to everything beneath.
There are two different types of tests that one can conduct: "glass box" and "black box". A "black box" test is implementation-agnostic; it is written based only on the documented behavior of the function/class and ensures that any arbitrary implemenation adheres to the documented behaviors. It may also include tests for potential errors that various theoretical implementations might make, but is done without regard to what the actual implementation does. By contrast, a "glass box" test is one which takes advantage of knowledge of the implementation and ensures that each code path in the implementation has been tested. A good test is one which consists of both comprehensive black box and glass box testing.
There are a number of different freely available libraries that make it easy to create unit tests. I strongly recommend using googletest and gmock (both used extensively at Google) for your testing.
Upvotes: 4
Reputation: 834
Unit tests involve testing individual classes or functions independent of the context they are normally associated with. This can cut down troubleshooting time by eliminating some of the guessing games involved when figuring out why exactly your code is causing errors. Unit tests are usually worth the time and effort involved for larger enterprise scale projects with large amounts of code or many people involved.
Upvotes: 2