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 using Nimble 5.0.0 & OCMock 3.3.1 #319

Closed
joeljfischer opened this issue Oct 18, 2016 · 5 comments
Closed

Crash using Nimble 5.0.0 & OCMock 3.3.1 #319

joeljfischer opened this issue Oct 18, 2016 · 5 comments

Comments

@joeljfischer
Copy link

I'm seeing a crash when running tests using the Swift 3 version of Quick / Nimble that I was not seeing on the Swift 2.3 version.

The test code causing the error:

expect(testManager.delegate).to(equal(managerDelegateMock)); // TODO: Broken on OCMock 3.3.1 & Swift 3 Quick / Nimble

The location it's breaking

// Stringers.swift
public func stringify<T>(_ value: T?) -> String {
    if let unboxed = value {
        return stringify(unboxed)
    }
    return "nil"
}

with this error:

Could not cast value of type 'OCProtocolMockObject' (0x11db0e518) to 'Swift.CustomDebugStringConvertible' (0x11d9ab0e8).
@joeljfischer
Copy link
Author

Also seeing this error elsewhere:

Could not cast value of type 'OCClassMockObject' (0x111f31518) to 'Swift.CustomDebugStringConvertible' (0x111e590e8).

for this code:

__block id fileManagerMock = OCMClassMock([SDLFileManager class]);
// ...
expect(testManager.fileManager).toNot(beNil());

@erikdoe
Copy link
Owner

erikdoe commented Oct 19, 2016

It feels like there are a lot of moving parts and I'm not sure I fully understand yet what you're doing.

It's clear that you are using the Nimble framework. From looking at its page on Github it looks like it's written in Swift but can be used from Objective-C, right? Based on the code snippet in your second comment I assume your tests are written in Objective-C, right?

Now, it sounds like you've updated the version of Nimble and kept the same version of OCMock. After the update of Nimble, some of your tests are breaking with this error you mention. If I understand you correctly the error occurs in the function you included in the issue. Where exactly? What are the arguments?

Could you provide a small self-contained tests that always fails?

@modocache
Copy link
Contributor

@joeljfischer I think this error should be fixed within Nimble itself. Could you close this issue and create one on the Nimble repository instead?

As the error message indicates, OCClassMockObject cannot be converted to Swift's CustomDebugStringConvertible protocol -- meaning, as far as I can tell, it doesn't implement -debugDescription. Nimble's stringify function attempts to handle cases in which the subject of an expectation doesn't conform to CustomDebugStringConvertible, so I'm not sure why it's failing here. But I think we can fix the problem in Nimble, rather than forcing OCMock code to change.

@erikdoe
Copy link
Owner

erikdoe commented Dec 13, 2016

Closing due to inactivity. Hopefully this has been fixed by the Nimble team. @modocache?

@modocache
Copy link
Contributor

Thanks, @erikdoe, I created an issue on the Nimble repository to track this.

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

No branches or pull requests

3 participants