la10736 / rstest

Fixture-based test framework for Rust
Apache License 2.0
1.19k stars 43 forks source link

unused warning for case variables used by fixture #[with(var)] #270

Open pitoniak32 opened 2 months ago

pitoniak32 commented 2 months ago

First off, I am a huge fan of this library. Thank you for creating this.

Usecase

I am creating some tests for database CRUD operations, and using some fixtures to offload the setup / seeding.

Description of Issue

One minor thing I see, is an unused warning for variables being used in #[with(var)] (Not sure if this was an intended usecase, or if I am missing an alternative)

This is very minor, just something I noticed. My workaround is to just silence them :)

#[allow(unused_variables)]
#[case] password: &str, 
#[allow(unused_variables)]
#[case] email: &str,

Example:

rs_test_warning

la10736 commented 2 months ago

Wow... The real world can go really far away from what you thought :smile: . In this case the compiler report unused variables because it's expecting to you use them in the test body and not before.

Anyway I'll think about this to check if I can find a nice way to express this use case. As work around you can prefix the variables with _ instead of to use annotation... But I know that's less than suboptimal.

Thanks

Il sab 10 ago 2024, 16:31 David Pitoniak @.***> ha scritto:

First off, I am a huge fan of this library. Thank you for creating this. Usecase

I am creating some tests for database CRUD operations, and using some fixtures to offload the setup / seeding. Description of Issue

One minor thing I see, is an unused warning for variables being used in

[with(var)] (Not sure if this was an intended usecase, or if I am

missing an alternative)

This is very minor, just something I noticed. My workaround is to just silence them :)

[allow(unused_variables)]

[case] password: &str,

[allow(unused_variables)]

[case] email: &str,

Example:

rs_test_warning.png (view on web) https://github.com/user-attachments/assets/4c702303-22b5-422f-935e-94c52e5ca9fd

— Reply to this email directly, view it on GitHub https://github.com/la10736/rstest/issues/270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5Y34KLTEZTSYST5UTQG73ZQYP5FAVCNFSM6AAAAABMJ4HP2OVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ2TSMJRGYYDSMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>