惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
GbyAI
GbyAI
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 叶小钗
A
About on SuperTechFans
M
MIT News - Artificial intelligence
宝玉的分享
宝玉的分享
雷峰网
雷峰网
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Martin Fowler
Martin Fowler
Google DeepMind News
Google DeepMind News
博客园 - Franky
B
Blog RSS Feed
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
The Mechanics Of Decision Of Test Double: Dummy
Azad Shukor · 2026-05-04 · via DEV Community

Azad Shukor

The most basic concept in test doubles is the dummy.

When testing a function, there are usually two kinds of input:

  1. Meaningful input

    Data that affects the result of the function.

  2. Dummy input

    Data that is required by the function, but does not affect the behavior we are testing.

Below is an example of meaningful data vs dummy data.

This is a calculateShipping function:

function calculateShipping(
  weight: number,
  user: { id: string },
  logger: { info: (message: string) => void }
) {
  return weight * 5;
}

Enter fullscreen mode Exit fullscreen mode

In this function, only weight affects the result.

The user and logger parameters are required, but they do not affect the shipping calculation.

const meaningfulWeight = 10;
const dummyUser = { id: "dummy-user" };
const dummyLogger = { info: () => {} };

const result = calculateShipping(
  meaningfulWeight,
  dummyUser,
  dummyLogger
);

expect(result).toBe(50);

Enter fullscreen mode Exit fullscreen mode

In this test:

const meaningfulWeight = 10;

Enter fullscreen mode Exit fullscreen mode

is meaningful input because changing it changes the result.

For example:

calculateShipping(10, dummyUser, dummyLogger); // 50
calculateShipping(20, dummyUser, dummyLogger); // 100

Enter fullscreen mode Exit fullscreen mode

But these two values are dummy inputs:

const dummyUser = { id: "dummy-user" };
const dummyLogger = { info: () => {} };

Enter fullscreen mode Exit fullscreen mode

They are only passed because calculateShipping() requires them.

Changing them does not change the result:

calculateShipping(10, { id: "user-1" }, dummyLogger); // 50
calculateShipping(10, { id: "user-2" }, dummyLogger); // 50

Enter fullscreen mode Exit fullscreen mode

So the purpose of a dummy is simple:

A dummy lets the function run without distracting the test from the behavior we actually care about.

In this case, we care about the shipping formula:

weight * 5

Enter fullscreen mode Exit fullscreen mode

We do not care about the user or logger.

That is why user and logger can be dummy values.

A dummy is useful because it keeps the test focused. Without naming something as dummy, future readers may wonder whether user or logger matters to the test.

By naming them dummyUser and dummyLogger, we are saying clearly:

This value is only here because the function requires it. It is not part of the behavior being tested.