Running individual tests in VS Code

In VS Code it is possible to run individual tests or individual module tests using buttons added right inside the text editor. It is very handy.
image

But I have to questions:

  1. Is it possible to specify custom arguments to test build? I.e. "--target" or "--release".

  2. When using additional attributes, like timeout from ntest these buttons do not show up. Can this be fixed?
    image

For question 1, you can do it project-wide with the setting rust-analyzer.runnables.extraArgs.

1 Like

For 2, does reversing make a difference...

#[timeout(500)]
#[test]
fn test_pt1_result() -> Result<()> {

I think it's a bug in ntest. other attributes works fine. for example, you can test it out by defining an identity proc macro attribute yourself like this:

#[proc_macro_attribute]
pub fn identity(_attrs: TokenStream, item: TokenStream) -> TokenStream {
	item
}
#[test]
#[dummy::identity]
fn test() {}

It makes the test not recognizable by the rust test framework. cargo test will skip this test like it does not exist.

It works. Not sure about the side effects as it can affect something else.

Huh. That seems like a bug. Bummer.