swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
709 stars 47 forks source link

Tests inside extensions are not listed correctly when parsing LSP test requests #778

Closed adam-fowler closed 1 month ago

adam-fowler commented 2 months ago

The follow code should generate two TestItems inside another

final class MyTests: XCTestCase {
    func test1() {
    }
}

extension MyTests {
    func test2() {
    }
}

In the TestExplorer you should get something like this

- MyTests
  - test1()
  - test2()

Currently they are getting listed as

- MyTests
  - test1()
- test2()
adam-fowler commented 2 months ago

Response to workspace/test

[Trace - 2:41:18 PM] Received response 'workspace/tests - (1)' in 415ms.
Result: [
    {
        "disabled": false,
        "tags": [],
        "style": "XCTest",
        "location": {
            "range": {
                "start": {
                    "character": 0,
                    "line": 2
                },
                "end": {
                    "character": 1,
                    "line": 5
                }
            },
            "uri": "file:///home/vscode/new-project/Tests/new-projectTests/MyTests.swift"
        },
        "label": "MyTests",
        "id": "MyTests",
        "children": [
            {
                "id": "MyTests/test1()",
                "children": [],
                "label": "test1()",
                "disabled": false,
                "style": "XCTest",
                "tags": [],
                "location": {
                    "range": {
                        "end": {
                            "character": 5,
                            "line": 4
                        },
                        "start": {
                            "character": 4,
                            "line": 3
                        }
                    },
                    "uri": "file:///home/vscode/new-project/Tests/new-projectTests/MyTests.swift"
                }
            }
        ]
    },
    {
        "disabled": false,
        "tags": [],
        "style": "XCTest",
        "location": {
            "uri": "file:///home/vscode/new-project/Tests/new-projectTests/MyTests.swift",
            "range": {
                "start": {
                    "line": 8,
                    "character": 4
                },
                "end": {
                    "line": 9,
                    "character": 5
                }
            }
        },
        "label": "test2()",
        "id": "MyTests/test2()",
        "children": []
    }
]