DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Full-Stack Observability Essentials: Explore the fundamentals of system-wide observability and key components of the OpenTelemetry standard.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • 7 Awesome Libraries for Java Unit and Integration Testing
  • Maven Plugin Testing - in a Modern Way - Part I
  • Unit Testing and Integration Testing in Practice
  • Jenkins H2 Database Integration Testing

Trending

  • SQL Query Performance Tuning in MySQL
  • How DevOps Can Cost You Millions if Not Implemented the Right Way
  • Application Integration for IoT Devices: A Detailed Guide To Unifying Your Ecosystem
  • How To Aim for High GC Throughput
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Unit Testing vs. Integration Testing: What's the Difference?

Unit Testing vs. Integration Testing: What's the Difference?

Let's help clarify the differences between unit testing and integration testing and look at what each of them mean and how they come together.

Leah Grantz user avatar by
Leah Grantz
·
Aug. 10, 18 · Presentation
Like (4)
Save
Tweet
Share
19.70K Views

Join the DZone community and get the full member experience.

Join For Free

Back in 2011, a couple of posts from our blog were focusing on the key differences between unit testing and integration testing. We thought now would be a great time to revisit this question, which comes up time and time again. In case you missed the original post, you can check it out — The Difference Between Unit Testing and Integration Testing, and come right back to this post where we'll break it down as simply as possible. Ready? Great, let's get started.

Unit Testing Defined

At its core, unit testing is a type of test to check if an individual small piece of code is doing what it is supposed to do. Sounds simple enough, right?
Unit tests are narrow in scope, they should be easy to write and execute, and their effectiveness depends on what the programmer considers to be useful. These minor, individual tests are intended for the use of the programmer and are not directly useful to anybody else. Done right, they can significantly cut down on fixing bugs in the later development stages.

Part of being a unit test is the implication that things outside of the code under test are mocked or stubbed out. Unit tests shouldn't have dependencies on outside systems, and that's where the lines between unit testing and integration testing get blurred. A unit test focuses on internal consistency as opposed to proving that they play nicely with outside systems.

Actually, "integration test" gets used for a wide variety of things, from full-on system tests against an environment made to resemble production to any test that uses a resource (like a database or queue) that isn't mocked out.

Integration Testing Defined

In comparison to unit test, Integration testing is a type of testing to check if different pieces of the modules work together as a whole.
In other words, integration tests cover the whole application, and they require much more effort to test effectively. They usually require resources like database instances and hardware to be allocated for them.

Integration Testing Methods

There are two fundamental ways of carrying out an integration test. The bottom-up method and the top-down method.
Bottom-up integration typically testing begins with unit testing, followed by tests of progressively higher-level combinations of units called modules or builds.

Alternatively, the top-down integration testing approach begins with the highest-level modules being tested first and progressively lower-level modules are tested afterwards. In a comprehensive software development environment, bottom-up testing is usually done first, followed by top-down testing. The process concludes with multiple tests of the complete application, preferably in scenarios designed to mimic those it will encounter in customers' computers, systems, and networks.

Bringing It All Together

Proper and consistent code testing ensures software that is a lot more effective at delivering the correct solution in a predictable and managed way. One of the biggest fears that programmers encounter is changing a piece of code without truly knowing what is going to break. Having a complete unit testing solution allows programmers to remove the fear of the unknown. Both unit testing and integration testing should never be left as an afterthought, but instead should always be an integral part of the development process.

unit test Integration testing Integration

Published at DZone with permission of Leah Grantz, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • 7 Awesome Libraries for Java Unit and Integration Testing
  • Maven Plugin Testing - in a Modern Way - Part I
  • Unit Testing and Integration Testing in Practice
  • Jenkins H2 Database Integration Testing

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: