<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/do-dtos-really-need-unit-tests--akqfulhvy" -->

---
title: Do DTOs really need unit tests? | daily.dev
description: A discussion question exploring whether Data Transfer Objects (DTOs) require unit tests. The author proposes a middle-ground approach: plain DTOs without logic...
canonical: https://daily.dev/posts/do-dtos-really-need-unit-tests--akqfulhvy
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Do DTOs really need unit tests? | daily.dev
og:description: A discussion question exploring whether Data Transfer Objects (DTOs) require unit tests. The author proposes a middle-ground approach: plain DTOs without logic...
og:url: https://daily.dev/posts/do-dtos-really-need-unit-tests--akqfulhvy
og:image: https://api.daily.dev/og/posts/aKQFUlHVY.png
og:image:alt: Do DTOs really need unit tests?
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Do DTOs really need unit tests?

**[Darijan Avric](https://daily.dev/sources/pegv5li26v6j98lzwbdjh)** · [@darijan_avric](https://daily.dev/darijan_avric) · 1 min read · 0 upvotes · 0 comments

## Summary

A discussion question exploring whether Data Transfer Objects (DTOs) require unit tests. The author proposes a middle-ground approach: plain DTOs without logic don't need tests, but DTOs with validation, transformation, or non-trivial mapping should be tested as they contain behavior. The post seeks community input on testing strategies, asking whether teams always test DTOs, never test them, only test those with validation/mapping, or rely solely on integration tests.

## Content

🧪 Curious how others handle this:

Do you unit test your DTOs? If yes, in which cases and how deep do you go?

My current take:
- Plain DTOs that are just data containers (no logic, no validation, no mapping) don’t really need unit tests.
- As soon as a DTO does validation, transformation or non‑trivial mapping, it *is* behavior and should be tested like any other piece of logic.

I’ve read articles that argue for this middle ground:  
✅ No tests for “dumb” data DTOs  
✅ Tests for DTOs that validate input, transform fields, or prepare data for other layers

How do you and your team treat DTOs?
- Always test them?
- Never test them?
- Only with validation/mapping?
- Integration tests only and no unit tests at all?

Really interested in concrete examples and trade‑offs rather than “it depends”. 🙂

## Similar posts on daily.dev

- [Should testers write unit tests?](https://daily.dev/posts/should-testers-write-unit-tests--djxyawoya) · On Test Automation · 0 upvotes · 0 comments
- [TDD is a Luxury: Pragmatic Testing for the Solo Developer](https://daily.dev/posts/tdd-is-a-luxury-pragmatic-testing-for-the-solo-developer-tawfchoo4) · Ruby Flow · 0 upvotes · 1 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#architecture](https://daily.dev/tags/architecture)

[View this post on daily.dev](https://daily.dev/posts/do-dtos-really-need-unit-tests--akqfulhvy)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/do-dtos-really-need-unit-tests--akqfulhvy","headline":"Do DTOs really need unit tests?","text":"A discussion question exploring whether Data Transfer Objects (DTOs) require unit tests. The author proposes a middle-ground approach: plain DTOs without logic don't need tests, but DTOs with validation, transformation, or non-trivial mapping should be tested as they contain behavior. The post seeks community input on testing strategies, asking whether teams always test DTOs, never test them, only test those with validation/mapping, or rely solely on integration tests.","url":"https://daily.dev/posts/do-dtos-really-need-unit-tests--akqfulhvy","datePublished":"2026-02-02T07:52:29.271Z","dateModified":"2026-02-02T07:52:46.946Z","author":{"@type":"Person","name":"Darijan Avric","url":"https://daily.dev/darijan_avric","image":"https://media.daily.dev/image/upload/s--2jasXMJu--/f_auto/v1770016790/avatars/avatar_pegV5Li26V6j98Lzwbdjh?_a=BAMAMiiu0","description":"Software Engineer | Angular, TypeScript, React | Node.js, NestJS, PostgreSQL | Enterprise Apps","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":60}},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/pegv5li26v6j98lzwbdjh","name":"Darijan Avric"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Darijan Avric","item":"https://daily.dev/sources/pegv5li26v6j98lzwbdjh"},{"@type":"ListItem","position":3,"name":"Do DTOs really need unit tests?"}]}
```

