Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add ability to use case name in parameter #279

Open
tbicr opened this issue Sep 28, 2024 · 1 comment
Open

Add ability to use case name in parameter #279

tbicr opened this issue Sep 28, 2024 · 1 comment

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants