Reputation: 25983
We've got a suite of UI tests for our app written using KIF which I'd like to convert to use the new Xcode UI test framework.
Some of our current tests work like this:
Assert that there are no objects in a core data table
Do some stuff in the UI
Assert that there are some objects in the core data table
Cancel the thing we were doing in the UI
Assert that there are no leaked objects in the core data table
I need to look at the actual core data store, not just the UI, because the leaked rows wouldn't necessarily be shown in the UI. How can I access a core data store from an Xcode UI test?
Upvotes: 2
Views: 1287
Reputation: 726
The answer is that you can't, not without abusing signals. XCUITests are not intended to touch the metal; they are intended to exercise user facing behavior only.
The test that you describe sounds like a perfectly good candidate for a unit test, though!
(based on comments from OP)
Well, as far as I can tell you have four options
Upvotes: 4
Reputation: 46718
You can easily test against Core Data but your test you described does not make much sense. If you are cancelling the UI action then Core Data does not save to disk. When you mention "table" that means to me that you are looking on disk.
If you want to load an empty Core Data store, create some objects, verify they were created, delete them and confirm they were deleted; that can all be done in a UI test.
What part are you having an issue with?
Upvotes: 0