Skip to content

Commit d8d6cd1

Browse files
committed
Test case for multiple extensions with no type declaration
1 parent adfae1a commit d8d6cd1

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Tests/SourceKitLSPTests/DocumentTestDiscoveryTests.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,64 @@ final class DocumentTestDiscoveryTests: XCTestCase {
11491149
)
11501150
}
11511151

1152+
func testSwiftTestingTwoExtensionsNoDeclaration() async throws {
1153+
let testClient = try await TestSourceKitLSPClient()
1154+
let uri = DocumentURI.for(.swift)
1155+
1156+
let positions = testClient.openDocument(
1157+
"""
1158+
import Testing
1159+
1160+
1️⃣extension MyTests {
1161+
3️⃣@Test func oneIsTwo() {}4️⃣
1162+
}2️⃣
1163+
1164+
extension MyTests {
1165+
5️⃣@Test func twoIsThree() {}6️⃣
1166+
}
1167+
""",
1168+
uri: uri
1169+
)
1170+
1171+
let tests = try await testClient.send(DocumentTestsRequest(textDocument: TextDocumentIdentifier(uri)))
1172+
XCTAssertEqual(
1173+
tests,
1174+
[
1175+
TestItem(
1176+
id: "MyTests",
1177+
label: "MyTests",
1178+
disabled: false,
1179+
isExtension: true,
1180+
style: TestStyle.swiftTesting,
1181+
location: Location(uri: uri, range: positions["1️⃣"]..<positions["2️⃣"]),
1182+
children: [
1183+
TestItem(
1184+
id: "MyTests/oneIsTwo()",
1185+
label: "oneIsTwo()",
1186+
disabled: false,
1187+
isExtension: true,
1188+
style: TestStyle.swiftTesting,
1189+
location: Location(uri: uri, range: positions["3️⃣"]..<positions["4️⃣"]),
1190+
children: [],
1191+
tags: []
1192+
),
1193+
TestItem(
1194+
id: "MyTests/twoIsThree()",
1195+
label: "twoIsThree()",
1196+
disabled: false,
1197+
isExtension: true,
1198+
style: TestStyle.swiftTesting,
1199+
location: Location(uri: uri, range: positions["5️⃣"]..<positions["6️⃣"]),
1200+
children: [],
1201+
tags: []
1202+
),
1203+
],
1204+
tags: []
1205+
)
1206+
]
1207+
)
1208+
}
1209+
11521210
func testFullyQualifySwiftTestingTestAttribute() async throws {
11531211
let testClient = try await TestSourceKitLSPClient()
11541212
let uri = DocumentURI.for(.swift)

0 commit comments

Comments
 (0)