为什么``货物测试''说“运行0个测试”在进行测试之前?

发布于 2025-01-26 08:34:07 字数 140 浏览 1 评论 0原文

我是Rust的新手,目前我正在尝试为现有脚本的重构版本创建测试用例。我注意到,每当我运行货物测试时,我首先收到消息“运行0个测试”,然后收到“运行X tests”(其中X x我编写的测试数)。

如何找到“运行0个测试”的来源?

I'm new to Rust and I'm currently trying to create test cases for a refactored version of an existing script. I noticed that for some reason whenever I run cargo test, I first receive the message "running 0 tests" and then "running x tests" (where x the number of tests I have written).

How can I find the source of "running 0 tests"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半边脸i 2025-02-02 08:34:07

Rust将其测试套件分为两个类别集成测试。单位测试在私有子模块下使用代码的其余部分进行源文件(通常称为mod Tests)。集成测试在一个称为test的单独板条箱中进行,完全与代码的其余部分完全脱节。前者可以在当前模块中访问私人数据,而后者被迫作为独立方互动。

货物测试首先运行单元测试,然后进行集成测试。如果您没有单位测试,它将通知您所有0个都已通过,然后继续进行您编写的测试。

Rust splits its testing suite into two categories: Unit and integration tests. Unit tests go in the source files with the rest of your code under a private submodule (usually conventionally called mod tests). Integration tests go in a separate crate called test completely disjoint from the rest of your code. The former has access to private data in the current module, whereas the latter is forced to interact with it as an independent party.

cargo test runs unit tests first, then integration tests. If you have no unit tests, it will inform you that all 0 of them have passed and then move on to the tests you wrote.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文