Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test discovery for XCTest #4

Open
Uncommon opened this issue Nov 27, 2024 · 2 comments
Open

Test discovery for XCTest #4

Uncommon opened this issue Nov 27, 2024 · 2 comments

Comments

@Uncommon
Copy link
Owner

Create a way to run specs easily under XCTest.

@Uncommon
Copy link
Owner Author

Uncommon commented Nov 27, 2024

Possibilities:

  • Use XCTestObservation.testSuiteWillStart() as an entry point. Hopefully adding tests to the suite at this point will work.
  • Like Quick does, use ObjC runtime calls to find all Rundown.TestCase subclasses and collect their test data
  • Quick uses method swizzling to support running a specific test class from Xcode; see if there's another way around this
  • How to create the XCTest objects?
    • init(selector:) doesn't say what object the selector will be called on.
    • init(invocation:) isn't usable in Swift because NSInvocation is unavailable; it's an ObjC runtime thing. Does this have to be done in ObjC?

@Uncommon
Copy link
Owner Author

Other notes on working with XCTest:

  • XCTContext requires the closure to be @MainActor. Is this a potential problem for some kinds of tests?
  • When running a specific test from Xcode, where does the test name/invocation come from? It doesn't seem to be a command line argument or environment variable.
  • Would it be good to follow the SwiftUI pattern and have each test be the test property of a class? Is it more desirable to have multiple test methods in a class, or does the describe/context/it structure make that unnecessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant