Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ability to use case name in parameter #279

Closed
tbicr opened this issue Sep 28, 2024 · 2 comments
Closed

Add ability to use case name in parameter #279

tbicr opened this issue Sep 28, 2024 · 2 comments

Comments

@tbicr
Copy link

tbicr commented Sep 28, 2024

I wrote integration tests that run queries in database and I want to isolate this test's queries.

Case name looks good option for me to achieve isolation and visibility, now I duplicate case name in parameter:

#[rstest]
#[case::standard("standard", "")]
#[case::concurrent("concurrent", " CONCURRENTLY")]
fn test(#[case] case: &str, #[case] suffix: &str) {
   // CREATE TABLE test_{case} (...)
}

In general it works fine except situation when cases copy-pasted a lot and it require both places fix to avoid isolation issues.

Option when I can use case name as case parameter looks good improvement for my workflow:

#[rstest]
#[case::standard("")]
#[case::concurrent(" CONCURRENTLY")]
fn test(#[case_name] case: &str, #[case] suffix: &str) {
   // CREATE TABLE test_{case} (...)
}

I wonder if rstest has something similar or you can suggest how it can be implemented best way?

@la10736
Copy link
Owner

la10736 commented Sep 29, 2024

You can use something like in #177 . Anyway I would find some time to implement the #[context] attribute.

@tbicr
Copy link
Author

tbicr commented Oct 1, 2024

This works perfectly, thanks.

@tbicr tbicr closed this as completed Oct 1, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants