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

Attempted to report a test failure to XCTest while no test case was running #1101

Open
Bogdan-Belogurov opened this issue Nov 21, 2023 · 6 comments

Comments

@Bogdan-Belogurov
Copy link

Bogdan-Belogurov commented Nov 21, 2023

What did you do?

Upgraded the Nimble to 13.0.0 from 9.2.0 and Quick to 7.3.0 from 4.0.0 to use AsyncSpec

What did you expect to happen?

AsyncSpec should notify about errors like regular QuickSpec.

What actually happened instead?

When I moved some tests to AsyncSpec.
and received: Attempted to report a test failure to XCTest while no test case was running. error.
Maybe you know how I can avoid this bug?

image

Environment

List the software versions you're using:

  • Quick: 13.0.0
  • Nimble: 7.3.0
  • Xcode Version: 14.3 (14E222b)
  • Swift Version: 5.8

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

  • Tuist 3.28.0

Project that demonstrates the issue

QuickProject.zip

To run the project:

  1. make tooling
  2. make project
  3. Run QuickProjectKitTests
@younata
Copy link
Member

younata commented Nov 23, 2023

What's the rest of the error? The message between the "Attempted to report a test failure to XCTest while no test case was running. The failure was:" and "It occurred at: [...]" lines. That'll help with determining what the actual issue is.

@Bogdan-Belogurov
Copy link
Author

Yes, you are right that's how I live now, but it's very difficult compared to the previous behavior.

@Bogdan-Belogurov
Copy link
Author

I uploaded a test project with the issue, please take a look.

@mokagio
Copy link
Member

mokagio commented Dec 8, 2023

I haven't looked at @Bogdan-Belogurov's example project, but I just got this unexpected behavior as well. Interestingly, I am also using Tuist.

@younata
Copy link
Member

younata commented Dec 8, 2023

This is caused by Nimble's CurrentTestCaseTracker.sharedInstance() not getting registered with XCTest. In particular, XCTestObservationCenter+Register.load's override isn't getting called.

Which appears to be caused by Tuist improperly handling Nimble's Package.swift (specifically, it looks like they're not including the NimbleObjectiveC stuff specified in our Package.swift). Until Tuist fixes this, I'd suggest following Tuist's documentation for using the native SPM integration.

I filed an issue with Tuist to hopefully get it resolved at some point.

@Narsail
Copy link

Narsail commented Jun 4, 2024

Alternatively what helped me was to make Nimble and its dependencies dynamic:

#if TUIST
    import ProjectDescription

    let packageSettings = PackageSettings(
        productTypes: [
            "Nimble": .framework,
            "CwlPreconditionTesting": .framework,
            "CwlPosixPreconditionTesting": .framework,
            "CwlCatchException": .framework,
            "NimbleObjectiveC": .framework,
            "CwlMachBadInstructionHandler": .framework
        ]
    )
#endif

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

4 participants