Skip to content

Support for #[rstest] tests #8964

@la10736

Description

@la10736

Hi,
an user of my crate ask a way to debug (but also just run today fails) #[rstest]'s tests la10736/rstest#120 . Today the lens appear correctly but the runner execute something like

cargo test --package <package> --bin <binary> -- <test_path> --exact --nocapture

That's ok if you have just a single test that use only fixtures but in the case you have cases or value list the procedural macro create a module that contains test functions or other modules.

So maybe in this case the best would be identify this as a Test module like it is.

Today rust-analyzer use a simple heuristic to identify test function (last argument path segment contains test word) and this work well to find rstest's ones, but look just hir cannot be useful to find how rstest expand it and crate a test module.

So if you are ok I can create a PR that simply catch rstest in runnable_fn and return a RunnableKind::TestMod instead of a RunnableKind::Test.

I know that a catch of explicit rstest is not the best but I don't have any better idea.

Let me know if you like it and I can send a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions