Introduction to Unit Testing

FREE On-Demand Webinar: How to succeed unit testing

 (Presented by Gil Zilberfeld - Product Manager)

 What you will get:
  Secret tips that will make you a unit testing success
  What it takes to be really agile
  How to test legacy code
  How unit tests save you debugging time

Over 2500 of your colleagues have already participated.
These developers have stated that they

  • Have Tried TDD or unit testing, but felt it wasn't going as smoothly as described in tutorials you've seen
  • Felt frustrated with the process and quit.
  • Found that Legacy code is a huge problem.

Watch the webinar to discover how you can succeed with unit testing
Register on the right and we will send you a link to the full online recording

"Gil shows an exciting approach to unit testing legacy code. Can't really think of anything you should try to improve." – Doug B, Sr. Lead
 

Gil Zilberfeld, Typemock's Product Manager, has over 18 years of experience and is a well know speaker at developer conferences around the world and an Agile practitioner

To watch, register on the right and we will send you a link to the full online recording.

Register here to get your FREE Content

 

 

The following article appeared in Sys-Con on May 24, 2011

The Difference Between Unit Testing and Integration Testing

This article will discuss how to prevent your unit tests turning into integration tests. 

By Gil Zilberfeld

First things first: 

What is a unit test?

A unit test is:

By breaking any of these guidelines, you increase the chance of developers either not trusting or not believing the test results (due to repeated false failures by the tests), or people not wanting to run the tests at all because they run too slowly.

What is an integration test?
An integration test is any test that can't be described as a unit test. The different kinds of integration tests (performance tests, system tests, acceptance tests etc.) are not the subject of this piece. Our main concern here is just differentiating unit tests from everything else.

An integration test might:

Taking those bullets into account, we can say that Integration tests will most likely:

When do integration tests make sense?
Integration tests can make a lot of sense in most systems in two particular configurations:

Additional regression test layer
Integration tests can serve as an extra "smoke test" that can be run when the full system needs to be tested, proving that deployment of all the system components works well, for example. With those kinds of tests, you would test many small things in one large test case.

Integration tests on legacy code
Michael Feathers, in his book "Working Effectively with Legacy Code" defined legacy code as "code that does not have tests." It's usually hard or impossible to write unit tests for such code, as it is mostly untestable. Tools like Typemock Isolator help relieve that problem by being able to fake anything, and integration tests can serve as an additional smoke test to make sure you didn't break the integration between system components, one level above unit tests.

Summary
By being able to distinguish unit from non-unit tests, we can make sure they are separated in our projects, and give our developers a "safe green zone" (as mentioned in Roy Osherove's book ‘The Art of Unit Testing') that contains only unit tests, in which developers can run and always trust the results.

•   •   •

Continue with Part 2: Best-even Introduction to Unit Testing  by Gil Zilberfeld
-Discover how you can master unit testing- fast

 

With over 15 years of experience in software development, Gil has worked with a range of aspects of software development, from coding to team management, and implementation of processes. Gil presents, blogs and talks about unit testing, and encourages developers from beginners to experienced, to implement unit testing as a core practice in their projects.