@@ -43,7 +43,7 @@ fn runnable_fn(fn_def: ast::FnDef) -> Option<Runnable> {
4343 let name = fn_def. name ( ) ?. text ( ) . clone ( ) ;
4444 let kind = if name == "main" {
4545 RunnableKind :: Bin
46- } else if fn_def . has_atom_attr ( "test" ) {
46+ } else if has_test_related_attribute ( & fn_def ) {
4747 RunnableKind :: Test { name : name. to_string ( ) }
4848 } else if fn_def. has_atom_attr ( "bench" ) {
4949 RunnableKind :: Bench { name : name. to_string ( ) }
@@ -53,6 +53,20 @@ fn runnable_fn(fn_def: ast::FnDef) -> Option<Runnable> {
5353 Some ( Runnable { range : fn_def. syntax ( ) . text_range ( ) , kind } )
5454}
5555
56+ /// This is a method with a heuristics to support test methods annotated with custom test annotations, such as
57+ /// `#[test_case(...)]`, `#[tokio::test]` and similar.
58+ /// Also a regular `#[test]` annotation is supported.
59+ ///
60+ /// It may produce false positives, for example, `#[wasm_bindgen_test]` requires a different command to run the test,
61+ /// but it's better than not to have the runnables for the tests at all.
62+ fn has_test_related_attribute ( fn_def : & ast:: FnDef ) -> bool {
63+ fn_def
64+ . attrs ( )
65+ . filter_map ( |attr| attr. path ( ) )
66+ . map ( |path| path. syntax ( ) . to_string ( ) . to_lowercase ( ) )
67+ . any ( |attribute_text| attribute_text. contains ( "test" ) )
68+ }
69+
5670fn runnable_mod ( db : & RootDatabase , file_id : FileId , module : ast:: Module ) -> Option < Runnable > {
5771 let has_test_function = module
5872 . item_list ( ) ?
0 commit comments