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

Crash Current context must not be nil with swift-testing #915

Closed
jcubit opened this issue Oct 6, 2024 · 2 comments · Fixed by #916
Closed

Crash Current context must not be nil with swift-testing #915

jcubit opened this issue Oct 6, 2024 · 2 comments · Fixed by #916

Comments

@jcubit
Copy link

jcubit commented Oct 6, 2024

Describe the bug
I am running into an uncaught exception “Terminating app due to uncaught exception NSInternalInconsistencyException, reason: Current context must not be nil” when snapshot testing a string. The problem only occurs when the test fails. There is no problem at all when recording.

This is not an async test.

To Reproduce

Fresh new project

import Testing
import SnapshotTesting

struct SomeTests {
    @Test
    func this_test_crashes_when_assertion_fails() throws {
        withSnapshotTesting {
            assertSnapshot(of: "foo", as: .lines)
        }
    }
}

Expected behavior
Maybe I am missing something fundamental in the new snapshottesting setup, but this should not crash and I should get a diff in Xcode.

Screenshots
Similar screenshot as in #875

Environment

  • swift-snapshot-testing version 1.17.5
  • Xcode 16.0 (16A242d)
  • Swift 6.0
  • OS: macOS 15.0.1 (24A348)

Additional context
This is not an async test, so #822 and #875 solutions do not apply here

Thank you in advance for looking into this!

@mbrandonw
Copy link
Member

Hi @jcubit, thanks for the report! There's definitely something to fix here, and not sure how we missed it. There's a chance something changed between the Xcode 16 beta and final release. But either way, #916 will fix it.

@jcubit
Copy link
Author

jcubit commented Oct 6, 2024

Thank you for your quick answer (and for this Package)! 🙏

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

Successfully merging a pull request may close this issue.

2 participants