Automated Unit Testing: Advantages & Best Practices

Instructor: David Gloag

David has over 40 years of industry experience in software development and information technology and a bachelor of computer science

Testing is an important part of software development, both from confidence and quality perspectives. In this lesson, we'll take a look at what unit testing is and what automated unit testing is, as well as some advantages and best practices.

Ensuring Product Use

Item quality is an important aspect of a product these days. For some, it is a differentiator between competing products. For others, it is a necessary process if the producer wishes to sell anything. Can you imagine a medication that hasn't been rigorously tested? Would you see yourself driving a vehicle that hasn't gone through the needed safety tests? Or can you think of yourself giving an infant a toy that hasn't passed government safety tests? Most of us can't. The same is true for software. Users won't purchase and deploy software that hasn't been thoroughly tested. Users can tell if a product hasn't been tested as it will show in the defects they encounter. So how do developers meet this need? How do they ensure that their products are rigorously tested? There are a number of methods, but most start with unit testing.

What Is Unit Testing?

Unit testing is testing that occurs at the smallest programming unit level, typically the function, procedure, or method. Each of the programming units is treated as a separate entity, and tested as if it stands alone. Think of it like how you would install and test a new home entertainment system. You wouldn't hook everything up and hope for the best. Instead you would run the wires to the speakers and connect them to the receiver, then run a white noise test. After that you would hook up your tuner, try a radio station, and so forth. The process would be systematic and incremental, much the same as unit testing.

What Is Automated Unit Testing?

Automated unit testing extends the idea of unit testing to the programmatic realm. In particular, the tests themselves are coded in the programming language being used and run against their individual program units as part of the build process. Think of them like the self-tests that many electronic devices have built-in and run when you power them on. For automated unit testing, this means that each time the system is built (which can be several times a day) these automated tests are run and the results of those tests gathered. In the end, developers get an up-to-the-minute look at the quality of the system being developed.

What Are Some Advantages of Automated Unit Testing?

Automated unit testing provides a number of advantages. Some of the more notable advantages are that it:

  • Catches Problems Early - Unit tests are developed at the same time a module is developed, so you get testing on that unit right from the start.
  • Reduces Side-Effects - Changes in one module can cause problems in another (side-effects). Unit testing discovers these problems right away so they can be addressed.
  • Writes Once, Runs Many - Once a unit test is created, it can be used as many times as you like. In essence, you get a constant level of protection against defects.
  • Lets Your Testers Focus on Other Things - Unit testing is tedious and time consuming. Automation lets your testers focus on other things that give you more bang for the buck, like user interface testing or usability testing.

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account