知识卡片

普通读书笔记卡 · 6075.d.1.a · 生成模型:未记录

集成测试按使用者验证

理解等级:中级

在项目根目录的 tests/ 添加集成测试文件,Cargo 把顶层测试文件编译为独立 crate。用例像外部用户一样通过库的公开 API 组合功能。适合捕捉组件单独工作正常、合在一起才出错的情况。可用 cargo test --test 目标名 定向运行。

相关卡片 [[单元测试贴近实现]]

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 编写自动化测试 Integration Tests · 查看原书依据

      In Rust, integration tests are entirely external to your library. They use your library in the same way any other code would, which means they can only call functions that are part of your library’s public API. Their purpose is to test whether many parts of your library work together correctly.

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第11章 编写自动化测试(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c11.xhtml`,块 0203) - 结论依据:原文解释了外部 crate 使用公开 API 与检查组件配合之间的关系。 - 原始内容:In Rust, integration tests are entirely external to your library. They use your library in the same way any other code would, which means they can only call functions that are part of your library’s public API. Their purpose is to test whether many parts of your library work together correctly.