sourcekit-lsp icon indicating copy to clipboard operation
sourcekit-lsp copied to clipboard

Tests inside extensions are not nested correctly in documentText/tests and workspace/tests responses

Open plemarquand opened this issue 1 year ago • 1 comments

Requests to documentText/tests and workspace/tests should generate two TestItems inside a top level MyTests TestItem with the following code.

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

extension MyTests {
    func test2() {
    }
}

Expected:

- MyTests
  - test1()
  - test2()

Actual:

- MyTests
  - test1()
- test2()

This is the root issue for https://github.com/swift-server/vscode-swift/issues/778.

plemarquand avatar May 03 '24 14:05 plemarquand

Synced to Apple’s issue tracker as rdar://127491907

ahoppen avatar May 03 '24 14:05 ahoppen

A related test case with swift-testing that doesn't work with extensions; foo is ~dropped~. Correction, its not dropped but there are two root TestItems returned with the same ID:

@Suite struct TestSuite {
  @Test func foo() {}
}

extension TestSuite {
  @Test func bar() {}
  @Test func baz() {}
}

Result:

- TestSuite
  - bar
  - baz

plemarquand avatar May 06 '24 13:05 plemarquand