diff --git a/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift b/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift index 9ac9c6264..b65a6a62e 100644 --- a/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift +++ b/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift @@ -149,14 +149,6 @@ struct TestDeclarationMacroTests { "Attribute 'Test' cannot be applied to a function within structure 'S' because its conformance to 'Escapable' has been suppressed", "struct S: ~(Escapable) { @Test func f() {} }": "Attribute 'Test' cannot be applied to a function within structure 'S' because its conformance to 'Escapable' has been suppressed", - - // empty display name string literal - #"@Test("") func f() {}"#: - "Attribute 'Test' specifies an empty display name for this function", - ##"@Test(#""#) func f() {}"##: - "Attribute 'Test' specifies an empty display name for this function", - #"@Suite("") struct S {}"#: - "Attribute 'Suite' specifies an empty display name for this structure", ] ) func apiMisuseErrors(input: String, expectedMessage: String) throws { @@ -241,6 +233,62 @@ struct TestDeclarationMacroTests { ), ] ), + + // empty display name string literal + #"@Test("") func f() {}"#: + ( + message: "Attribute 'Test' specifies an empty display name for this function", + fixIts: [ + ExpectedFixIt( + message: "Remove display name argument", + changes: [ + .replace(oldSourceCode: #""""#, newSourceCode: "") + ]), + ExpectedFixIt( + message: "Add display name", + changes: [ + .replace( + oldSourceCode: #""""#, + newSourceCode: #""\#(EditorPlaceholderExprSyntax("display name"))""#) + ]) + ] + ), + ##"@Test(#""#) func f() {}"##: + ( + message: "Attribute 'Test' specifies an empty display name for this function", + fixIts: [ + ExpectedFixIt( + message: "Remove display name argument", + changes: [ + .replace(oldSourceCode: ##"#""#"##, newSourceCode: "") + ]), + ExpectedFixIt( + message: "Add display name", + changes: [ + .replace( + oldSourceCode: ##"#""#"##, + newSourceCode: #""\#(EditorPlaceholderExprSyntax("display name"))""#) + ]) + ] + ), + #"@Suite("") struct S {}"#: + ( + message: "Attribute 'Suite' specifies an empty display name for this structure", + fixIts: [ + ExpectedFixIt( + message: "Remove display name argument", + changes: [ + .replace(oldSourceCode: #""""#, newSourceCode: "") + ]), + ExpectedFixIt( + message: "Add display name", + changes: [ + .replace( + oldSourceCode: #""""#, + newSourceCode: #""\#(EditorPlaceholderExprSyntax("display name"))""#) + ]) + ] + ) ] }