Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find rust test binary for my project?

Tags:

rust

I'm having problem on a specific function of a test of a specific file:

mod test {
//...

 #[test]
    #[cfg(feature = "proto-igmp")]
    fn test_handle_igmp() {

I've found here https://github.com/rust-lang/cargo/issues/1407 that I can test specific tests by passing its name as an argument to the test binary. But where's such binary? And can I make println work inside tests?

I want to run test_handle_igmp to print some things and see why the error is happening.

like image 659
Guerlando OCs Avatar asked Nov 06 '25 15:11

Guerlando OCs


1 Answers

You can find it in target/$MODE/$NAME-$hash, e.g. target/debug/example-3beac917983bc7e3.exe. Note that there might be multiple ones, some for doc tests, some for #[test] functions.

That being said if you just want to run test_handle_igmp, you can just use

cargo test test_handle_igmp -- --nocapture

to run your test and see the println outputs. See cargo test --help or the online documentation.

like image 197
Zeta Avatar answered Nov 09 '25 09:11

Zeta