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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Creating AI Data Analyst With DBeaver
  • Mastering Database Unit Testing: A Full Guide and 5 Essential Tools
  • Testing Level Dynamics: Achieving Confidence From Testing
  • Technology for People: How to Develop an Engineering Culture and Make a Quantum Leap In Development

Trending

  • Unmasking Entity-Based Data Masking: Best Practices 2025
  • Apache Doris vs Elasticsearch: An In-Depth Comparative Analysis
  • Solid Testing Strategies for Salesforce Releases
  • Simplify Authorization in Ruby on Rails With the Power of Pundit Gem
  1. DZone
  2. Data Engineering
  3. Databases
  4. Defining Test Boundaries — An Example

Defining Test Boundaries — An Example

With the multiplicity of tests of all types that need to be performed on an application, it's important to understand where one ends and another begins.

By 
Victor Chircu user avatar
Victor Chircu
·
Jun. 12, 19 · Analysis
Likes (1)
Comment
Save
Tweet
Share
5.3K Views

Join the DZone community and get the full member experience.

Join For Free

I think that everybody agrees that testing is required in order to build a quality product. But there’s also a lot of confusion about the boundaries of each test type. What’s the scope of a unit test? What’s the difference between an integration test, an integrated test and a contract test? If you ask three developers about test boundaries, you’ll most likely get three different answers. For example, I still talk to people who consider that a unit test should test a single class/method.

What’s clear is that most teams don’t have a consensus on what’s the scope of the different types of automated tests and the differences between them. Getting to a universal consensus might be hard, but getting to a consensus inside the team should be easy enough. In this blog post, we’ll see an example of how to do that.

Start With The System’s Architecture

I’m a fan of lightweight documentation. So I think that the best way to define the different test types is to start with the high-level architecture of your system. Here is an example:

High Level Architecture

On the front end, we have a single page application. It’s composed of different components. (As a note, I’m more of a back end developer, that’s why I only mention the front end in this post, without going into too many details.)

If we zoom into the back end part, it looks like this:

High Level Architecture - Back end

This example uses the Clean Architecture style with three layers:

  • The Domain layer contains the domain model.
  • The Application layer abstracts the low-level details of the domain model behind more coarse-grained application use cases.
  • The Infrastructure layer contains the low-level details of the infrastructure. Here you’ll find the presentation layer (e.g. Controllers), repository implementations, gateways to third parties, queues, access to the file system, etc.

I find it useful to put example of classes from the actual system, just so it’s easier for the team members to know what we’re talking about.

Defining Test Types

With a visualization of our architecture at hand, we can start defining test boundaries and scope. This should be as easy as drawing boundaries around different elements from our architecture.

Unit Tests

I like Ian Cooper's definition of a unit test – a test that doesn’t cross a port. For our example, if it’s not touching the network, the file system, etc., then it’s a unit test:

Unit test boundaries

This diagram clearly shows some example of unit tests:

  • It can test a single class
  • It can test a group of classes
  • It can span the application and the domain layer

It also shows that unit tests don’t cross a port and don’t touch external dependencies (e.g. databases, file systems).

Component Tests

A component test exercises the component through its public interface. In our case this means you might send a JSON request:

Component test boundaries

Component tests still run in process. As you can see, we’re not testing external systems. For example, we’ll use a fake for the Product Catalog, instead of the SQL implementation.

Integration Tests

Integration tests check the integration between two components. They are very focused and their scope is very narrow. They will test against the real dependencies. In our case, this means testing the real database and a sandbox version of the Payment Provider.

Integration test boundaries

HTTP API Tests

At the next level, we have HTTP API Tests. This is what Martin Fowler calls Subcutaneous tests – tests that run at the layer immediately below the UI. These tests need the service to be up and running, because they test the external components (e.g. databases and third-party services).

HTTP API test boundaries

End-to-End

Of course, end-to-end tests exercise the system through the UI. This can be done using UI automation tools like Cypress or Selenium WebDriver.

End-to-end test boundaries


Conclusion

I find it useful to get a consensus inside the team on the scope and purpose of different types of tests. You might not agree with the definitions from this article and that’s OK. What’s important is to speak the same language inside the team. And this should be easy to do. Get the team together, draw the architecture of your system and then start defining the scope of each test type. After getting to a common understanding, save the output of the discussion in your team’s wiki. It might also be useful to link to a couple of examples for each test type. This can help while on-boarding new team members.

If you want to see more example of testing strategies, have a look at these resources:

  • "Testing Strategies in a Microservice Architecture" by Toby Clemson
  • "Testing Strategies in Interaction-Driven Design" by Sandro Mancuso (video here). (As a note, I’ve been on his Crafting Code and Crafted Design courses and they’re really good. You can read my notes here.)
  • A simple test taxonomy from J. B. Rainsberger

Also, if you’re looking for ideas of how to improve your tests, check the Fifty Quick Ideas to Improve Your Tests book – it’s good.

If you know other good examples of test taxonomies for different types of system, please leave a comment.

unit test Database teams

Published at DZone with permission of Victor Chircu, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Creating AI Data Analyst With DBeaver
  • Mastering Database Unit Testing: A Full Guide and 5 Essential Tools
  • Testing Level Dynamics: Achieving Confidence From Testing
  • Technology for People: How to Develop an Engineering Culture and Make a Quantum Leap In Development

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • 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:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!