<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>类型测试 on PlumePHP</title><link>https://plumephp.com/tags/%E7%B1%BB%E5%9E%8B%E6%B5%8B%E8%AF%95/</link><description>Recent content in 类型测试 on PlumePHP</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Mon, 28 Sep 2026 10:00:00 +0800</lastBuildDate><atom:link href="https://plumephp.com/tags/%E7%B1%BB%E5%9E%8B%E6%B5%8B%E8%AF%95/index.xml" rel="self" type="application/rss+xml"/><item><title>TypeScript 测试策略：单元测试、类型测试与测试替身实战</title><link>https://plumephp.com/typescript-testing-type-safe/</link><pubDate>Mon, 28 Sep 2026 10:00:00 +0800</pubDate><guid>https://plumephp.com/typescript-testing-type-safe/</guid><description>&lt;h2 id="引言"&gt;引言&lt;/h2&gt;
&lt;p&gt;TypeScript 项目有两类「错误」要防：&lt;strong&gt;运行时的逻辑错误&lt;/strong&gt;（用单元/集成测试）和&lt;strong&gt;编译期的类型错误&lt;/strong&gt;（用类型检查）。但 TS 的类型系统只保证「类型一致」，不保证「业务正确」；反过来，测试只验证「运行行为」，不一定验证「类型契约」——&lt;strong&gt;两者要一起上&lt;/strong&gt;。更妙的是，TS 能测「类型本身」：断言某个类型恰好等于另一个类型、某个泛型的结果符合预期。&lt;/p&gt;</description></item></channel></rss>