la10736 / rstest

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

allow to run individual parametrized test cases from vscode? #195

Closed anthrotype closed 1 year ago

anthrotype commented 1 year ago

as you know, Visual Studio Code lets one run specific tests (when you hover on a test function it detects it is a test and shows a "Run Test" button above it that will call cargo test with that specific test selected). When I use rstest with multiple parametrized cases, multiple Run Test labels will appear but they will be all in one line and get easily truncated on the right if there are lots of them and the screen is not wide enough, see:

Screenshot 2023-04-27 at 18 36 46

Ideally the "Run Test" button would appear right above each #[case(...)] attribute.

I noticed this because I was previously using https://github.com/foresterre/yare to do the parameterized testing and for that one, somehow, vscode can identify the sub-tests and show distinct Run Test buttons above each case definition, e.g.:

image

I am a newbie and have no idea how these procedural macros even work, but wanted to ask in case anybody knows more, feel free to close thanks.

la10736 commented 1 year ago

rstest doesn't have any control over it. The parameterized test cases are desugared as a test module that contains some tests functions (I'm simplifying it). Maybe vscode can move gutter icons aside the case attribute but should introduce a rstest specific hook... I don't think they will do it.

Il giorno gio 27 apr 2023 alle ore 19:41 Cosimo Lupo < @.***> ha scritto:

as you know, Visual Studio Code lets one run specific tests (when you hover on a test function it detects it is a test and shows a "Run Test" button above it that will call cargo test with that specific test selected). When I use rstest with multiple parametrized cases, multiple Run Test labels will appear but they will be all in one line and get easily truncated on the right if there are lots of them and the screen is not wide enough, see:

[image: Screenshot 2023-04-27 at 18 36 46] https://user-images.githubusercontent.com/6939968/234943839-1f9ccda9-1aaa-4a5d-a1e7-15148128febf.png

Ideally the "Run Test" button would appear right above each #[case(...)] attribute.

I noticed this because I was previously using https://github.com/foresterre/yare to do the parameterized testing and for that one, somehow, vscode can identify the sub-tests and show distinct Run Test buttons above each case definition, e.g.:

[image: image] https://user-images.githubusercontent.com/6939968/234945343-905c820b-9ead-48e5-b0c2-9403a671ae5a.png

I am a newbie and have no idea how these procedural macros even work, but wanted to ask in case anybody knows more, feel free to close thanks.

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