[英]How to unit test outside of main.rs?
I'm new to Rust, I have a file structure like this我是 Rust 的新手,我有这样的文件结构
main.rs主要.rs
chip8.rs芯片8.rs
chip8_gui.rs chip8_gui.rs
I added a unit test in main.rs and a unit test in chip8.rs (a simple assert_eq,(2,2)
) but it only finds the test in main.rs.我在 main.rs 中添加了一个单元测试,在 chip8.rs 中添加了一个单元测试(一个简单的assert_eq,(2,2)
),但它只在 main.rs 中找到测试。 Why?为什么? I am trying to test a private function of chip8.rs.我正在尝试测试 chip8.rs 的私有 function。
Turns out TDD is fun, but you have to make sure it compiles!事实证明 TDD 很有趣,但你必须确保它可以编译! The solution was simply to add mod chip8
in main.rs
解决方案只是在main.rs
中添加mod chip8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.