-
Notifications
You must be signed in to change notification settings - Fork 582
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
Tests don't run and crash with error #661
Comments
Same issue happens at the attempt to verify cURL snapshot produced by async networking method. |
This is part of a broader problem, it seems like |
This definitively does occur for us with Swift's actor-based concurrency. For UI-based tests e.g., I could see that there could be a main-thread dependency. But our tests in this case only use JSON-serialization, so I think it's rather odd that this would be confined to the main-thread. If there was an actual dependency, then shouldn't the API be annotated with |
This issue's been open for quite a while but I don't seem to find any PR to address it. Makes me wonder wether maybe I am holding it wrong? For my use, I am adding Or is there a way do get around this without these overloads (and without having to dispatch calls to For reference, here are my overloads: @MainActor
public func assertSnapshotAsync<Value, Format>(
matching value: @autoclosure () throws -> Value,
as snapshotting: Snapshotting<Value, Format>,
named name: String? = nil,
record recording: Bool = false,
timeout: TimeInterval = 5,
file: StaticString = #file,
testName: String = #function,
line: UInt = #line
) async {
assertSnapshot(
matching: try value(),
as: snapshotting,
named: name,
record: recording,
timeout: timeout,
file: file,
testName: testName,
line: line
)
}
@MainActor
public func assertSnapshotsAsync<Value, Format>(
matching value: @autoclosure () throws -> Value,
as strategies: [String: Snapshotting<Value, Format>],
record recording: Bool = false,
timeout: TimeInterval = 5,
file: StaticString = #file,
testName: String = #function,
line: UInt = #line
) async {
assertSnapshots(
matching: try value (),
as: strategies,
record: recording,
timeout: timeout,
file: file,
testName: testName,
line: line
)
} |
Same issue here. This is extremely confusing and annoying since many of our tests involve async processing for things like network requests or parsing. |
This is happening with Xcode 15.2 as well. private class CleanCounterBetweenTestCases: NSObject, XCTestObservation {
private static var registered = false
private static var registerQueue = DispatchQueue(label: "co.pointfree.SnapshotTesting.testObserver")
static func registerIfNeeded() {
// Running on background thread, which is not allowed on XCTest with iOS 17.2
registerQueue.sync {
if !registered {
registered = true
XCTestObservationCenter.shared.addTestObserver(CleanCounterBetweenTestCases())
}
}
}
func testCaseDidFinish(_ testCase: XCTestCase) {
counterQueue.sync {
counterMap = [:]
}
}
} |
Describe the bug
The test crash with the following assertion failing:
Expected behavior
Expected tests to run.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
Additional context
Add any more context about the problem here.
The text was updated successfully, but these errors were encountered: