Reputation: 21528
I'm developing my UI test with Swift 3.0 using Realm 2.4.2.
How can I "see" both on test target and application same realm objects?
What I do not want to do is using the launchArguments
workaround delegating app to create objects.
Upvotes: 0
Views: 971
Reputation: 27620
You cannot "see" the same Realm objects in your UITest target and your Application because those two are running as completely separated processes.
From Apple's docs:
UI testing exercises your app's UI in the same way that users do without access to your app's internal methods, functions, and variables. ... Your test code runs as a separate process, synthesizing events that UI in your app responds to.
In other words: Your UITests are running in a separate App that interacts with your main App (when you run a UITest you can see the Testrunner App being launched and closed before your main App is being launched). Those two apps can not share objects.
I see two directions that you could go:
1. Create the cat objects via your app's UI
Somewhere you probably have a "Add cat" button. Press that in your UITest, add a cat like a use would and then assert that the cat has been added to the list. That is what UITests are for. Using the app like a user would and testing the results of a user's interaction with the app.
2. Use UnitTests:
If you want to test that a created Realm cat object is populating a list a UnitTest might be the better way. During a UnitTest you have full access to your app's code. So you can create a cat object in your test code and the app will "see" it.
Upvotes: 2