SShortSingh.
Back to feed

Slow test suites often measure database overhead, not actual code logic

0
·8 views

A common reason test suites run slowly is that every test connects to a real PostgreSQL instance and runs migrations, even when the test itself never truly needs database interaction. The real cost is not total runtime but the delay between writing code and getting feedback, which breaks developer focus. The recommended fix is to apply the database schema once per session and wrap each test in a transaction that rolls back automatically, eliminating repeated setup overhead. Developers should distinguish tests that genuinely require database behavior — such as queries, constraints, or transaction boundaries — from those that merely use the database as a convenient way to build objects. Keeping a small, clearly marked set of true database integration tests while converting the rest to use plain objects can significantly reduce per-test setup cost.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Five Free Hosting Platforms With Custom Domains Compared for 2026

A developer spent a month benchmarking five free hosting platforms — GitHub Pages, Netlify, and others — after realizing paid hosting was no longer necessary for static sites and Flutter web apps. The comparison evaluates each platform across five criteria: custom domain support, free-tier limits, deployment workflow, extra features, and hidden catches. GitHub Pages scored highly for reliability and generous bandwidth but lacks serverless or dynamic capabilities, making it ideal for simple projects. Netlify added value through deploy previews, built-in forms, and edge functions, though its free-tier build minutes can run out quickly with frequent deployments. The findings suggest developers can host side projects at no cost in 2026, provided they choose a platform whose limitations align with their specific use case.

0
ProgrammingDEV Community ·

38 Practical Dart & Flutter Tips Drawn From 4 Years of Production Experience

A Flutter developer with over four years of production experience has compiled 38 actionable Dart and Flutter tips sourced from code reviews, real bugs, and hands-on experimentation. The guide covers areas such as safer null handling using pattern matching, cleaner list construction, and exhaustive switch statements that catch unhandled cases at compile time. It also addresses when to skip async/await boilerplate, how to write more readable test assertions, and the importance of documenting lint-warning suppressions for team clarity. Each tip is framed around what it does, why it matters, and when it should actually be applied, rather than offering generic best-practice advice. The collection targets developers looking to reduce production incidents and improve code maintainability through small, consistently applied decisions.

0
ProgrammingDEV Community ·

Why 'send(message)' Hides a Web of Contracts in Distributed Systems

In distributed computing, the simple function call send(message) conceals a range of complex and distinct behaviors that systems must explicitly define. The key distinction lies between transient communication, where message delivery requires both sender and receiver to be active simultaneously, and persistent communication, where infrastructure stores the message until the recipient is ready. A second axis separates synchronous messaging, where the sender waits for some form of acknowledgment, from asynchronous messaging, where the sender hands off responsibility and moves on immediately. Each combination carries different guarantees around message durability, ordering, and what actually constitutes a successful delivery. Understanding these hidden contracts is essential for building reliable distributed systems, as vague semantics that work in human communication can cause hard-to-debug failures in software.

0
ProgrammingDEV Community ·

Why Remote Procedure Calls Can Never Truly Mimic Local Function Calls

Remote Procedure Call (RPC) is a widely used abstraction that allows developers to invoke functions on remote machines as if they were local, hiding the complexity of network communication. Before any call is made, it must be serialized into bytes, transmitted over protocols like TCP or UDP, and reconstructed on the receiving end — a process invisible to the application developer. While this abstraction simplifies development, it conceals fundamental differences between local and remote execution, including byte-order mismatches, encoding inconsistencies, and data serialization challenges. The original RPC model, described by Birrell and Nelson and formalized in standards like ONC RPC, centers on a stub-based mechanism where client and server stubs handle message construction and argument reconstruction. Understanding where this abstraction breaks down is critical for building reliable distributed systems, particularly when network failures, latency, or data representation differences come into play.