Skip to content

Tag test class that indirectly subclasses XCTestCase #49

@humblehacker

Description

@humblehacker

The following query tags classes that inherit XCTestCase as swift_xctest_class, but only if subclassed directly. In our codebase, we have our own base test case class that subclasses XCTestCase, and all of our tests subclass that (and sometimes even deeper).

;; XCTestCase subclass
(
(class_declaration
name: (type_identifier) @SWIFT_TEST_CLASS
(inheritance_specifier
inherits_from: (user_type
(type_identifier) @run (#eq? @run "XCTestCase")
)
)
) @_swift-xctest-class
(#set! tag swift-xctest-class)
)

I don't know much about treesitter scm. Is there a way to modify this query so that my test case classes are tagged with swift_xctest_class?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions