Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Sporadic results in XCTest #1350
Using Xcode 6.1.1, Swift, and Realm 0.88, I'm getting some weird results with testing RLMObjects.
When testing the success of a model's creation, tests will (in a seemingly random fashion) pass or fail. I'm assuming this relates to the race conditions, as described here: https://groups.google.com/d/msg/realm-cocoa/LZQou7g8or8/lSmoy5beTRIJ.
I'm using the SwiftTestCase as a base test class: https://groups.google.com/d/msg/realm-cocoa/LZQou7g8or8/lSmoy5beTRIJ. With one addition: since my models always use the
When testing a model function that creates a user, something along the lines of this:
With a simple test such as:
The test will sporadically pass or fail.
Is there something else I should be doing to alleviate the issue?
Hi @bredfield, I'm sorry this is causing you some problems. It doesn't look like you're doing anything wrong from what you've told us.
We'll need access to an Xcode project where we can reproduce this issue to troubleshoot further. Do you think you could send us anything? You can email us code privately at firstname.lastname@example.org if you prefer.
Great find! Have you run into any similar dynamic casting issues previously? Is there a preferred way to cast to the object's class?
Another Note: A forced downcast does cause a
Hi all, thanks for your patience on this. The problem demonstrated in the example project created by @bredfield was caused by compiling an RLMObject subclass in both the app and test targets.
tl;dr; don't add your app's Swift files to your unit test targets.
Please read bredfield/RealmTest#1 for a more detailed explanation of what was happening and how it can be fixed.